Jon Test
C++ Unit Test Tool. Not for production -- sample code only
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
JonTest::TestSuiteTyped< TestSuiteDerived > Class Template Reference

Holds and runs Test Cases as a single Test Suite. More...

#include <TestSuiteTyped.h>

Inheritance diagram for JonTest::TestSuiteTyped< TestSuiteDerived >:
Inheritance graph
Collaboration diagram for JonTest::TestSuiteTyped< TestSuiteDerived >:
Collaboration graph

Public Types

typedef TestSuiteDerived TestSuite
 The actual Test Suite class.
 
typedef void(TestSuite::* TestCaseMethod) ()
 The actual Test Suite Method type for test cases.
 

Public Member Functions

const std::string & getName () const
 Returns the name of this Test Suit.
 
virtual bool isValid (const std::string &caseName) const
 
void add (const char *const testCaseName, TestCaseMethod const testCaseMethod)
 Add TestCaseMethod by name to this Test Suite.
 
virtual int listTestCases (std::ostream &out) const
 List available Test Cases to out.
 
virtual Count run (Logger &logger)
 Run all Test Cases in the Test Suite giving events to logger.
 
virtual Count run (Logger &logger, const std::string &testCase)
 Runs the given testCase in this Test Suite.
 
- Public Member Functions inherited from JonTest::TestSuiteInterface
virtual ~TestSuiteInterface ()
 Destructor – does nothing.
 
virtual void setup ()
 The Test Suite runsthis prior to each test case.
 
virtual void teardown ()
 The Test Suite runs this after to each test case.
 

Protected Member Functions

 TestSuiteTyped (const char *const suiteName)
 Create the Test Suite by name and add it to the TestRunner singleton.
 
virtual ~TestSuiteTyped ()
 

Private Attributes

const std::string suiteName
 Name of this Test Suite.
 
std::map< std::string, TestCase< TestSuite > > cases
 Map of Test Case name to TestCase<TestSuite> cases.
 

Detailed Description

template<typename TestSuiteDerived>
class JonTest::TestSuiteTyped< TestSuiteDerived >

Holds and runs Test Cases as a single Test Suite.

Main automatic Test Suite implementation with TestSuite naming the derived class for pointer-to-member.

Provides the map of Test Case name to

Template Parameters
TestSuiteDerivedThe actual Test Suite class, required for TestCase<>.

Definition at line 28 of file TestSuiteTyped.h.

Member Typedef Documentation

◆ TestCaseMethod

typedef void(TestSuite::* JonTest::TestSuiteTyped< TestSuiteDerived >::TestCaseMethod) ()

The actual Test Suite Method type for test cases.

Definition at line 35 of file TestSuiteTyped.h.

◆ TestSuite

The actual Test Suite class.

Definition at line 32 of file TestSuiteTyped.h.

Constructor & Destructor Documentation

◆ TestSuiteTyped()

JonTest::TestSuiteTyped< TestSuiteDerived >::TestSuiteTyped ( const char *const  suiteName)
inlineprotected

Create the Test Suite by name and add it to the TestRunner singleton.

Restricted to derived classes.

Parameters
suiteNameName of this test suite

Definition at line 49 of file TestSuiteTyped.h.

◆ ~TestSuiteTyped()

Definition at line 57 of file TestSuiteTyped.h.

Member Function Documentation

◆ add()

void JonTest::TestSuiteTyped< TestSuiteDerived >::add ( const char *const  testCaseName,
TestCaseMethod const  testCaseMethod 
)
inline

Add TestCaseMethod by name to this Test Suite.

Parameters
testCaseNameName of the Test Case
testCaseMethodTestSuite method of the Test Case

Definition at line 77 of file TestSuiteTyped.h.

◆ getName()

const std::string & JonTest::TestSuiteTyped< TestSuiteDerived >::getName ( ) const
inline

Returns the name of this Test Suit.

<

Returns
the name of this Test Suite.

Definition at line 63 of file TestSuiteTyped.h.

◆ isValid()

virtual bool JonTest::TestSuiteTyped< TestSuiteDerived >::isValid ( const std::string &  caseName) const
inlinevirtual
Returns
true if caseName can be run, otherwise false

Implements JonTest::TestSuiteInterface.

Definition at line 68 of file TestSuiteTyped.h.

◆ listTestCases()

virtual int JonTest::TestSuiteTyped< TestSuiteDerived >::listTestCases ( std::ostream &  out) const
inlinevirtual

List available Test Cases to out.

<

Returns
the number of test cases

Implements JonTest::TestSuiteInterface.

Definition at line 89 of file TestSuiteTyped.h.

◆ run() [1/2]

virtual Count JonTest::TestSuiteTyped< TestSuiteDerived >::run ( Logger logger)
inlinevirtual

Run all Test Cases in the Test Suite giving events to logger.

<

Returns
Count of tests run and failed in this Test Suite.
Parameters
loggerThe logger for events issued while running this test

Implements JonTest::TestSuiteInterface.

Definition at line 111 of file TestSuiteTyped.h.

◆ run() [2/2]

virtual Count JonTest::TestSuiteTyped< TestSuiteDerived >::run ( Logger logger,
const std::string &  testCase 
)
inlinevirtual

Runs the given testCase in this Test Suite.

Note
If testCase is not valid, it will result in an error, and the returned count of running 1 test, and failing 1 test.
Returns
the Count of tests run and tests failed in this Test Suite.
Parameters
loggerto log events of running the test suite and cases
testCaseto run

Implements JonTest::TestSuiteInterface.

Definition at line 138 of file TestSuiteTyped.h.

Member Data Documentation

◆ cases

std::map<std::string, TestCase<TestSuite> > JonTest::TestSuiteTyped< TestSuiteDerived >::cases
private

Map of Test Case name to TestCase<TestSuite> cases.

Definition at line 42 of file TestSuiteTyped.h.

◆ suiteName

const std::string JonTest::TestSuiteTyped< TestSuiteDerived >::suiteName
private

Name of this Test Suite.

Definition at line 39 of file TestSuiteTyped.h.


The documentation for this class was generated from the following file: