How to define order for test cases under same group

565 views
Skip to first unread message

ajish alfred

unread,
Jul 19, 2016, 10:22:59 AM7/19/16
to cpputest
Hi all,

I would like to know is there a method to define the order of test cases under a same test group.

Suppose I have a test group like this,

TEST_GROUP (Group1)
{
       ;
}

and three test cases like,

TEST (Group1, Test1)
{
     ;
}

TEST (Group1, Test2)
{
     ;
}

TEST (Group1, Test3)
{
     ;
}

I would like to run all test cases at once, I'm just giving option [-v]. In few of my experiments I found that if I define test cases as above, it may not run in the order which I've written the test case
eg: TEST (Group1, Test3) may run before TEST (Group1, Test1).

Is there any way I can define the order in which the test cases can be run?

Thanks.

Ryan Hartlage

unread,
Jul 19, 2016, 10:26:31 AM7/19/16
to cpputest
Hey Ajish,

The tests run in reverse order, so you can reverse the tests. However,
needing your tests to run in a specific is a very big red flag. You
want your tests to be independent so that they can properly point you
to the correct failure and so that you can isolate failures to just
the code in a single test, so writing order-dependent tests is
something you should avoid at all costs.

Ryan
> --
> You received this message because you are subscribed to the Google Groups
> "cpputest" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cpputest+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

James Grenning

unread,
Jul 19, 2016, 11:30:31 AM7/19/16
to cpputest
I second Ryan's concern. Actually having the tests run from the bottom
of the file to the top, often finds static or global data that is not
properly initialized.

James

--------------------------------------------------------------------------
James Grenning - Author of TDD for Embedded C - wingman-sw.com/tddec
wingman-sw.com
wingman-sw.com/blog
twitter.com/jwgrenning
facebook.com/wingman.sw
[![wingman
software](http://www.wingman-sw.com/images/wingman.png)](http://wingman-sw.com)

ajish alfred

unread,
Jul 19, 2016, 10:44:46 PM7/19/16
to cppu...@googlegroups.com
Thanks Ryan and James. I took your point which is very much valid. I should try to make the test cases order independent.
However if there is a mechanism to define order or any workaround, please let me know.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages