SmartTester
2.0.0
Smart Tester is unit testing and regression testing framework used for testing SmartCGMS system.
|
#include <LogFilterUnitTester.h>
Public Member Functions | |
void | executeSpecificTests () override |
Executes all tests for a specific filter. Needs to be implemented by derived class. More... | |
HRESULT | logFileGenerationTest () |
HRESULT | logRowCountTest () |
HRESULT | filterOutputTest () |
HRESULT | eventOrderTest () |
HRESULT | popResultRepeatingTest () |
HRESULT | popEventCountTest () |
![]() | |
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 from GenericUnitTester responsible for testing of Log filter.
HRESULT tester::LogFilterUnitTester::eventOrderTest | ( | ) |
When there are events executed upon LogFilter in specific order, there should be records of these events in the log file in the same order. This test executes level, info and parameters event upon LogFilter and checks if the records of these events in the log file are in correct order.
If something went wrong, releasing all existing events
If something went wrong, releasing all existing events
+1 for the header
Checking second line - first line is header, third field is event code
|
overridevirtual |
Executes all tests for a specific filter. Needs to be implemented by derived class.
Configuration tests
the test above should create junk file so we delete it
Functional tests
Implements tester::FilterUnitTester.
HRESULT tester::LogFilterUnitTester::filterOutputTest | ( | ) |
When there is an event executed upon the LogFilter, there should be a line describing the executed event. This test executes one level event upon the LogFilter and then checks if the event was logged into the log file.
Checking second line - first line is header, third field is event code
HRESULT tester::LogFilterUnitTester::logFileGenerationTest | ( | ) |
If LogFilter is successfully configured with Log_File attribute value present, text file with identical name should be created. This method tests if it is true. Returns S_OK only if the log file is created, otherwise returns E_FAIL.
File should exist already after successful configuration
HRESULT tester::LogFilterUnitTester::logRowCountTest | ( | ) |
When there is N events executed upon the LogFilter, there should be a line for every single event that was executed, plus one for the header. This test will execute 3 level events and a shutdown event upon the LogFilter and checks, whether there are 5 lines present in the generated log file.
If creating failed, setting flag to failed
If something went wrong, releasing all existing events
If something went wrong, releasing all existing events
Forcing logs to be displayed in the log
Here not returning E_FAIL, will try to check the log anyways
+2 for header and shut down event
HRESULT tester::LogFilterUnitTester::popEventCountTest | ( | ) |
Executing Pop method should always return a line for every event, that was executed upon the filter. This test executes three level events upon the LogFilter and checks, whether the Pop method returns tree log records.
HRESULT tester::LogFilterUnitTester::popResultRepeatingTest | ( | ) |
Executing Pop method should always return the difference between this and the last calling. This test executes level event and checks the Pop interface twice. At first Pop should return the executed event and the second time the event should not be returned anymore.
Popping the same event for the second time should return false