Jon Test
C++ Unit Test Tool. Not for production -- sample code only
Loading...
Searching...
No Matches
Macros
TestSuite.h File Reference
#include "JonTest/TestCase.h"
#include "JonTest/TestSuiteTyped.h"
Include dependency graph for TestSuite.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TEST_SUITE(testSuiteName)
 Defines a Test Suite named testSuiteName.
 
#define TEST_SUITE_END()
 Finish definition of a Test Suite started with TEST_SUITE().
 
#define TEST_CASE(testCaseName)
 Defines a Test Case method named testCaseName within a Test Suite defined by TEST_SUITE().
 

Macro Definition Documentation

◆ TEST_CASE

#define TEST_CASE (   testCaseName)
Value:
JonTest::TestCase<SuiteName> testCaseName ##_holder = JonTest::TestCase<SuiteName>::createAndAdd(*this, #testCaseName, &SuiteName::testCaseName); \
void testCaseName()
Defines and runs a single Test Case within a Test Suite.
Definition TestCase.h:18
static TestCase createAndAdd(TestSuite &suite, const char *const testCaseName, TestCaseMethod const testCaseMethod)
Creates TestCase and adds the Test Case to the suite.
Definition TestCase.h:34

Defines a Test Case method named testCaseName within a Test Suite defined by TEST_SUITE().

Parameters
testCaseNameName of Test Suite suitable for a class name.

This creates a function named testCaseName and a helper named testCaseName with "_holder" appended to automatically register the Test Case.

See also
TEST_SUITE()
Examples
SimpleTest.cpp, TestCaseOrder.cpp, assertBool_test.cpp, assertComparison_test.cpp, assertException_test.cpp, assertFail_setup.cpp, assertFail_teardown.cpp, assertFail_test.cpp, and assertPtr_test.cpp.

Definition at line 91 of file TestSuite.h.

◆ TEST_SUITE

#define TEST_SUITE (   testSuiteName)
Value:
namespace { \
class testSuiteName \
: public JonTest::TestSuiteTyped<testSuiteName> \
{ \
private: \
typedef testSuiteName SuiteName; \
public: \
testSuiteName() : TestSuiteTyped(#testSuiteName) {}
Holds and runs Test Cases as a single Test Suite.

Defines a Test Suite named testSuiteName.

Parameters
testSuiteNameName of Test Suite suitable for a class name.

This creates a class named testSuiteName obeying the TestSuiteInterface, and a single unique instance of the class which is automatically registered with TestRunner.

When running this Test Suite, each Test Case defined by TEST_CASE() will be called as:

  • testSuiteName::setup()
  • testSuiteName::testCaseName()
  • testSuiteName::teardown()

The user is free to add data members and member functions to support testing provided:

  • They do not have conflicting names with TestSuiteTyped<>
  • They do not require memberwise initialization within testSuiteName's constructor(s)

Typical usage:

TEST_SUITE(MyTestSuite)
std::string value1;
std::string value2;
void setup()
{
value1 = "some string value";
value2 = "another";
}
void teardown()
{
value1.clear()
value2.clear*()
}
TEST_CASE(testFeatureA)
{
....
}
TEST_CASE(testFeatureB)
{
....
}
...
END_TEST_SUITE()
#define TEST_CASE(testCaseName)
Defines a Test Case method named testCaseName within a Test Suite defined by TEST_SUITE().
Definition TestSuite.h:91
#define TEST_SUITE(testSuiteName)
Defines a Test Suite named testSuiteName.
Definition TestSuite.h:63
See also
TEST_CASE()
TEST_SUITE_END()
Examples
SimpleTest.cpp, TestCaseOrder.cpp, assertBool_test.cpp, assertComparison_test.cpp, assertException_test.cpp, assertFail_setup.cpp, assertFail_teardown.cpp, assertFail_test.cpp, and assertPtr_test.cpp.

Definition at line 63 of file TestSuite.h.

◆ TEST_SUITE_END

#define TEST_SUITE_END ( )