A Discrete-Event Network Simulator
API

Example use of TestSuite. More...

#include "ns3/test.h"
+ Include dependency graph for sample-test-suite.cc:

Go to the source code of this file.

Classes

class  ns3::tests::SampleTestCase1
 This is an example TestCase. More...
 
class  ns3::tests::SampleTestSuite
 The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases to be run. More...
 

Namespaces

 ns3
 Every class exported by the ns3 library is enclosed in the ns3 namespace.
 
 ns3::tests
 Namespace for test files, TestCases and TestSuites.
 

Variables

static SampleTestSuite ns3::tests::g_sampleTestSuite
 SampleTestSuite instance variable. More...
 

Detailed Description

Example use of TestSuite.

Assume this is the test suite for class Class in module 'module'.

Document the file as follows. (Note: for purposes of this illustration Doxygen comments are set off with triple ‘\\\’; you should use the normal Javadoc format. )

Add it to the groups module-tests and class-tests:

/// \file
/// \ingroup module-tests
/// \ingroup class-tests
/// Class test suite. 

Define the class-tests group:

/// \ingroup module-tests
/// \defgroup class-tests Class test suite 

Make sure test.h is included:

#include "ns3/test.h" 

Put the test code in namespace ns3::tests.

namespace ns3 {
  namespace tests { 

Write your test cases and final test suite, and put them in your test group:

/// \ingroup class-tests
class ClassTestSuite : public TestSuite {...}; 

Create a static variable to hold the instance of your test suite:

/// \ingroup class-tests
/// ClassTestSuite instance variable.
static ClassTestSuite g_classTestSuite; 

Finally, close the ingroup and namespace blocks:

}  // namespace tests
}  // namespace ns3 

Definition in file sample-test-suite.cc.