SmartTester
2.0.0
Smart Tester is unit testing and regression testing framework used for testing SmartCGMS system.
|
#include <ModelUnitTester.h>
Public Member Functions | |
ModelUnitTester (const GUID &guid, const std::wstring &libPath) | |
void | executeSpecificTests () override |
Executes all tests for a specific filter. Needs to be implemented by derived class. More... | |
HRESULT | modelFlagTest () |
HRESULT | modelCreationTest (const scgms::NModel_Flags &modelFlag) |
HRESULT | invalidParameterCountTest () |
HRESULT | initializePositiveCurrentTimeTest () |
HRESULT | repeatedInitializeCallTest () |
HRESULT | stepBeforeInitializeTest () |
HRESULT | negativeStepDeltaTimeTest () |
HRESULT | currentTimeStepTest () |
HRESULT | futureTimeStepTest () |
![]() | |
FilterUnitTester (GUID guid, const EntityType &type) | |
HRESULT | infoEventTest () |
HRESULT | warningEventTest () |
HRESULT | errorEventTest () |
HRESULT | warmResetEventTest () |
HRESULT | shutDownEventTest () |
void | executeConfigTest (const std::wstring &testName, const tester::FilterConfig &configuration, HRESULT expectedResult) |
void | executeAllTests () override |
Every derived class has to override this method to execute all tests. More... | |
void | executeGenericTests () |
![]() | |
EntityUnitTester (const GUID &entityGuid) | |
bool | isEntityLoaded () const noexcept |
CDynamic_Library & | getEntityLib () noexcept |
const GUID & | getEntityGuid () const noexcept |
void | loadEntityLibrary () |
const wchar_t * | getEntityName (const std::string &symbolName) |
![]() | |
void | executeTest (const std::wstring &testName, const std::function< HRESULT(void)> &test) |
Additional Inherited Members | |
![]() | |
HRESULT | configurationTest (const tester::FilterConfig &config, HRESULT expectedResult) |
HRESULT | shutDownTest () override |
Creates shut down event and executes it with tested filter. | |
HRESULT | configureFilter (const tester::FilterConfig &configuration) |
TestFilter & | getTestFilter () |
![]() | |
void | setEntityLib (const std::wstring &libPath) |
void | setLibraryPath (const std::wstring &libraryPath) noexcept |
const std::wstring & | getLibraryPath () const |
scgms::IFilter * | getTestedEntity () noexcept |
void | setTestedEntity (scgms::IFilter *entity) |
void | runTest (const std::function< HRESULT()> &test) override |
We need special behavior of the test execution sequence, so we override this method. More... | |
![]() | |
std::mutex | m_testMutex |
std::condition_variable | m_testCv |
HRESULT | m_lastTestResult = S_OK |
Derived class with tests for individual models.
HRESULT tester::ModelUnitTester::currentTimeStepTest | ( | ) |
When Step method is called with time_advance_delta = 0.0, current state should always be emitted. This test checks, whether events emitted by calling Step(0.0), even after stepping by N, represent current time state of the model.
Checking state in time 0
Epsilon for comparing double values
Moving by 0.6
Checking state in time += 0.6
Clearing events so we can tell when nothing was sent to us
Checking current state in the stepped time
|
overridevirtual |
Executes all tests for a specific filter. Needs to be implemented by derived class.
Continuing with tests for discrete models
Executing generic tests after we executed and passed all the construction tests
Implements tester::FilterUnitTester.
HRESULT tester::ModelUnitTester::futureTimeStepTest | ( | ) |
When Step method is called with positive time_advance_delta, future state of N units from now should be emitted. This test checks, whether any events are emitted and if so, whether they represent the right time or not.
Checking state in time 1
Epsilon for comparing double values
HRESULT tester::ModelUnitTester::initializePositiveCurrentTimeTest | ( | ) |
Calling initialize method of a model while passing positive current_time value should not result in an error. This test checks, whether the initialization with positive time passes or not.
HRESULT tester::ModelUnitTester::invalidParameterCountTest | ( | ) |
When the vector of parameters, passed to the model constructor, is shorter that it's descriptor says it should be, filter should not be created. This test checks, if the size of given vector is validated.
Making sure we get invalid number of parameters
HRESULT tester::ModelUnitTester::modelCreationTest | ( | const scgms::NModel_Flags & | modelFlag | ) |
If model has Discrete_Model flag, it should be possible to construct its object, otherwise it should not be possible. This test checks, whether the model can be created and returns result based on given flags of the model.
modelFlag | flags of created model |
HRESULT tester::ModelUnitTester::modelFlagTest | ( | ) |
Every model should have Discrete_Model of Signal_Model flag in the descriptor. This test checks if one of these flags is in model's descriptor.
HRESULT tester::ModelUnitTester::negativeStepDeltaTimeTest | ( | ) |
Step method has to he called with non-negative time_advance_delta, because it says the state in which time should be emitted. This test checks whether calling Step method with negative time_advance_delta returns an error or not.
HRESULT tester::ModelUnitTester::repeatedInitializeCallTest | ( | ) |
Initialization of a model should be allowed to happen only once. When called repeatedly, every other initialization should fail with E_ILLEGAL_STATE_CHANGE error. This test checks whether all following initializations fail with expected error or not.
HRESULT tester::ModelUnitTester::stepBeforeInitializeTest | ( | ) |
Step method must not be called before Initialize was called. This test checks, whether calling Step before Initialize returns an error or not.
Trying to emit current state