semantics of DoSetup() and DoTeardown() and AddTestCase() in TestCase

35 views
Skip to first unread message

Hans van den Bogert

unread,
Jun 10, 2014, 10:27:29 AM6/10/14
to ns-3-...@googlegroups.com
Hi,

I'm not sure how to use the testing framework works because I'm not sure how the semantics are meant to be.

In other testing frameworks a class can be under test and a test can have multiple test-cases.

1) I saw a TestCase in NS-3 can have child test-cases, by calling AddTestCase() -- can the 'parent' TestCase be seen as a Test-class i.e. comparable to a jUnit's Test-class?

2) In jUnit derivatives, a setup-method in a Test-class is called before each testCase method, however in the NS-3 test framework a setup method is only called once, can I thus say that a setup-method is comparable to teardownClass method in jUnit semantics?

3) Is there a way to have setup/teardown methods which are called before and after a collection of TestCase-s ? E.g. I have TestCase1, TestCase2 and TestCase3, and a common setup method, the common setup method would be called before each of the TestCase-s.

Thank you in advance for any comments,




Nat P

unread,
Jun 17, 2014, 9:24:14 AM6/17/14
to ns-3-...@googlegroups.com


Il giorno martedì 10 giugno 2014 16:27:29 UTC+2, Hans van den Bogert ha scritto:
Hi,

I'm not sure how to use the testing framework works because I'm not sure how the semantics are meant to be.

In other testing frameworks a class can be under test and a test can have multiple test-cases.

1) I saw a TestCase in NS-3 can have child test-cases, by calling AddTestCase() -- can the 'parent' TestCase be seen as a Test-class i.e. comparable to a jUnit's Test-class?

TestSuite can have multiple TestCases (added through AddTestCase)
 

2) In jUnit derivatives, a setup-method in a Test-class is called before each testCase method, however in the NS-3 test framework a setup method is only called once, can I thus say that a setup-method is comparable to teardownClass method in jUnit semantics?

I do not remember jUnit very well, but you're right, the entrance point of the TestCase is DoRun (where usually Simulator::Run is invoked) and the exit point is DoTeardown

3) Is there a way to have setup/teardown methods which are called before and after a collection of TestCase-s ? E.g. I have TestCase1, TestCase2 and TestCase3, and a common setup method, the common setup method would be called before each of the TestCase-s.


It could be achieved by calling explicitly in the DoRun method:

DoRun ()
{
  Setup ()
  TestCase ()
  Teardown ()

  Setup ()
  TestCase2 ()
  Teardown ()
}

In this PoC the Simulator::{Run,Destroy} part is omitted, but if needed it should be added "in the right places".

Hans van den Bogert

unread,
Jun 20, 2014, 4:47:24 AM6/20/14
to ns-3-...@googlegroups.com
Ok, then I understood correctly, thanks for answering
Reply all
Reply to author
Forward
0 new messages