winIDEA SDK
|
This class encapsulates all data required for one test.
It is the top level class aggregating all other classes related to test specification. It may also contain children, which inherit parts of specification.
Python example from cumulativeModuleCoverage.py:
This class is directly or indirectly used in all test examples.
Python example with coverage.
Python example with module coverage.
Python example modifies function parameters.
#include <CTestSpecification.h>
Public Types | |
enum | ETestScope { E_UNIT_TEST , E_SYSTEM_TEST } |
Test scope. More... | |
enum | SectionIds |
Ids of test specification sections. | |
Public Member Functions | |
void | addChildAndSetParent (int idx, const CTestTreeNodeSPtr &testSpec) override |
Adds given test specification to the list of derived specifications at the given index. | |
void | addDerivedTestSpec (int idx, CTestSpecificationSPtr testSpec) |
Adds given test specification to the list of derived specifications at the given index. | |
void | assignOptions (CTestSpecification &src) |
This method copies stubs from src to this object. | |
void | assignStubs (const CTestSpecificationSPtr &src) |
This method copies stubs from src to this object. | |
void | assignTestPoints (const CTestSpecificationSPtr &src) |
This method copies test points from src to this object. | |
void | assignUserStubs (const CTestSpecificationSPtr &src) |
This method copies stubs from src to this object. | |
void | clearEmptySections () |
This method releases all sections, which contain no data (only empty strings). | |
void | clearMergedFilterInfo (bool isClearRecursively) |
For optimization reasons test specification stores merged info during filtering. | |
CTestBaseSPtr | createInstance (const CTestBaseSPtr &parent) const override |
Creates an empty instance of this class. | |
CTestSpecification () | |
Should be used for root specification only. | |
CTestSpecification (const CTestSpecificationSPtr &parent) | |
Creates an empty instance with the given parent. | |
void | deleteAllDerivedTestSpecs () |
Deletes all derived test specifications. | |
int | deleteChild (const CTestTreeNodeSPtr &child) override |
Deletes the given derived test spec. | |
void | deleteDerivedTestSpec (int idx) |
Deletes test spec at the given index. | |
CTestSpecificationSPtr | findDerivedTestSpec (const std::string &testId, int recursiveLevel) |
This method returns the first derived test specification with the given ID. | |
int | findDerivedTestSpec (CTestSpecificationSPtr &testSpec) |
Returns index of the given test specification, or -1 if not found. | |
CTestAnalyzerSPtr | getAnalyzer (bool isConst) |
Returns analyzer configuration. | |
isys::CTestAssertSPtr | getAssert (bool isConst) |
Returns object containing assertions for test result. | |
std::string | getBaseId () |
Returns id of the parent. | |
isys::CTestStopConditionSPtr | getBeginStopCondition (bool isConst) |
Returns stop condition to be used before system test for target initialization. | |
CTestBaseSPtr | getCachedMergedTestSpec () |
Returns merged test spec, if set, null otherwise. | |
CTestBaseSPtr | getCachedMergedTestSpec (int sectionId) override |
If section is merged, returns cached merged test spec., which was set with setCachedMergedTestSpec(), else null is returned. | |
CTestBaseListSPtr | getChildren (bool isConst) override |
Returns pointer to the list of derives test cases. | |
virtual CTestTreeNodeSPtr | getContainerTestNode () override |
Always returns this. | |
std::string | getCoreId () |
Returns ID of CPU core, where this test case should be executed, or empty string if core ID is not specified. | |
isys::CTestAnalyzerCoverageSPtr | getCoverage (bool isConst) |
CTestSpecificationSPtr | getDerivedTestSpec (int idx) |
Returns derived test spec at the given index. | |
std::string | getDescription () |
Returns test description as specified in tag description. | |
isys::CTestDryRunSPtr | getDryRun (bool isConst) |
Returns Dry Run configuration. | |
CTestFunctionSPtr | getEndFunction (bool isConst) |
Returns specification for the end function, which is called immediately after the function under test is executed. | |
isys::CTestStopConditionSPtr | getEndStopCondition (bool isConst) |
Returns stop condition to be used as system test termination. | |
void | getExpectedResults (iconnect::StrVector &expectedResults) |
CTestFunctionSPtr | getFunctionUnderTest (bool isConst) |
Returns specification for the function under test. | |
isys::CTestHILSPtr | getHIL (bool isConst) |
Returns HIL configuration. | |
std::string | getId () override |
Return true, if there is no data in test specification. | |
isys::CTestImportsSPtr | getImports (bool isConst) |
Returns reference to modifiable specification of imports. | |
CTestFunctionSPtr | getInitFunction (bool isConst) |
Returns specification for the init function, which is called just before the function under test is executed. | |
iconnect::StrVector | getInitKeys () |
Returns vector with names of variables to be initialized. | |
void | getInitKeys (iconnect::StrVector &strVector) |
Returns the same info as getInitKeys(), but with original quoting. | |
void | getInitMap (iconnect::StrStrMap &initMap) |
Returns initialization assignments of local variables. | |
CTestFunctionSPtr | getInitTargetFunction (bool isConst) |
Returns specification for script function to be called before any test initialization is done. | |
void | getInitValues (iconnect::StrVector &values) |
Returns vector with values of variables to be initialized. | |
void | getLocalVariables (iconnect::StrStrMap &localVars) |
Returns local variables specified as a map of [var name, var type] pairs. | |
void | getLocalVariablesKeys (iconnect::StrVector &vars) |
Returns names of local variable in the same order as they were entered in test specification. | |
isys::CTestLogSPtr | getLog (bool isConst) |
Returns object containing expressions to be logged before test starts and when test ends. | |
CTestSpecification::ETestScope | getMergedTestScope () |
This method returns merged value of test scope section. | |
int | getNoOfDerivedSpecs () |
Returns the number of derived test specs. | |
int | getNoOfTests (bool isSkipAbstractTests) |
Returns the number of tests in this test specification - counts this specification and all derived tests. | |
iconnect::StrVector | getOptionKeys () |
Returns names of winIDEA options to be set. | |
void | getOptionKeys (iconnect::StrVector &strVector) |
Returns names of winIDEA options to be set with original quoting. | |
void | getOptionValues (iconnect::StrVector &values) |
Returns values of winIDEA options to be set. | |
CTestSpecificationSPtr | getParentTestSpecification () |
Returns parent test specification or NULL, if this is the root specification. | |
CTestPersistentVarsSPtr | getPersistentVars (bool isConst) |
Returns persistent variables. | |
void | getPositionParams (iconnect::StrVector ¶ms) |
Returns function parameters specified in 'func:' section. | |
isys::CTestAssertSPtr | getPrecondition (bool isConst) |
Returns object containing assertions to be verified before test start. | |
isys::CTestAnalyzerProfilerSPtr | getProfiler (bool isConst) |
CTestFunctionSPtr | getRestoreTargetFunction (bool isConst) |
Returns specification for script function to be called after test environment on the stack is destroyed. | |
iconnect::ETristate | getRunFlag () |
Returns run flag. | |
int | getSourceLineNumber () |
Returns number of the line in file, where this test spec is defined, or -1 if not set. | |
CTestStackUsageSPtr | getStackUsage (bool isConst) |
Returns settings for stack usage. | |
isys::CTestStubSPtr | getStub (const std::string &functionName) |
Returns stub object for the given function. | |
CTestBaseListSPtr | getStubs (bool isConst) |
Returns stubs in another type of container. | |
void | getTags (iconnect::StrVector &tags) |
Returns test tags as specified in tag tags. | |
std::string | getTestId () |
Deprecated since Jan 2016. | |
isys::CTestPointSPtr | getTestPoint (const std::string &testPointId) |
Returns test point object for the given id or NULL ptr if test point was not found. | |
int | getTestPointIdx (const std::string &testPointId) |
isys::CTestBaseListSPtr | getTestPoints (bool isConst) |
Returns reference to list of all test point specifications. | |
ETestScope | getTestScope () |
Returns test type - unit or system test. | |
int | getTestTimeout () |
Returns timeout (in milliseconds), after which test execution is terminated. | |
isys::CTestAnalyzerTraceSPtr | getTrace (bool isConst) |
std::string | getUILabel () override |
Returns label to be shown in testIDEA. | |
isys::CTestUserStubSPtr | getUserStub (const std::string &functionName) |
Returns user stub object for the given function. | |
CTestBaseListSPtr | getUserStubs (bool isConst) |
Returns reference to list of all user stub specifications. | |
std::string | getWarnings () |
If there were any warnings detected during parsing, this method returns non-empty string with description of warnings. | |
bool | hasChildren () override |
Returns true, if there are derived test specifications. | |
bool | hasPositionParams () |
Returns true, if there are function parameters specified in 'func:' section. | |
bool | isEmptyExceptDerived () |
Returns true, if test spec has no data, except derived test specs. | |
bool | isGroup () override |
Returns true, if this object is of type CTestGroup, false if it is CTestSpecification. | |
bool | isInheritSection (CTestSpecification::SectionIds sectionId) |
This method returns true, if isSectionMerged() returns true, AND this section is marked as inherited in the 'imports' section. | |
bool | isMerged () const override |
Returns true, if the CTestSpecification section containing this object is merged. | |
bool | isSectionMerged (SectionIds sectionId) |
This method returns true, if the section is defined in parent test spec, but not in this test spec. | |
bool | isTestSpecification () override |
Always returns true. | |
CTestSpecificationSPtr | merge () |
This method merges all parent test specifications with this one. | |
int | removeStub (const std::string &functionName) |
Removes stub with the given function name. | |
void | removeStub (int i) |
Removes stub. | |
int | removeUserStub (const std::string &functionName) |
Removes user stub with the given function name. | |
void | save (const std::string &fileName, bool isAppend=false) |
Writes test spec to the given file. | |
void | setBaseId (const std::string &testId) |
Sets parent id. | |
void | setCachedMergedTestSpec (CTestSpecificationSPtr &mergedTestSpec) |
Caches merged test spec. | |
void | setCoreId (const std::string &coreId) |
Sets core ID where this test case should be executed. | |
void | setDescription (const std::string &description) |
Sets description. | |
void | setExpectedResults (const iconnect::StrVector &expectedResults) |
void | setIdeOptions (const std::string &yamlSpec) |
Sets IDE options. | |
void | setInitValues (const std::string &yamlSpec) |
Sets initialization values of variables used in test. | |
void | setLocalVariables (const std::string &yamlSpec) |
Sets declarations of local variables used in test. | |
void | setMainMapStyle (isys::IEmitter::EYamlStyle mappingStyle) override |
Always sets mapping style to BLOCK. | |
void | setRunFlag (iconnect::ETristate isRun) |
Sets run flag. | |
void | setTags (const iconnect::StrVector &tags) |
Sets tags. | |
void | setTags (const std::string &tags) |
void | setTestId (const std::string &testId) |
Sets test id. | |
void | setTestScope (ETestScope testType) |
Sets test type. | |
void | setTestTimeout (int timeout) |
Sets timeout (in milliseconds), after which test execution is terminated. | |
Static Public Member Functions | |
static CTestSpecificationSPtr | cast (const CTestBaseSPtr &testBase) |
Casts the given object to this class. | |
static CTestSpecificationSPtr | load (const std::string &fileName, size_t filePos=0) |
Loads test specification from file. | |
static CTestSpecificationSPtr | parseTestSpec (const std::string &yamlSpec) |
Parses test specification in YAML format and returns new object containing the given information. | |
|
override |
Adds given test specification to the list of derived specifications at the given index.
Parent of the added test specification is set to 'this'! Use this method when modifying test specification tree.
idx | advice where to put test spec in the derived test spec list If -1 or out of range, the test spec is added to the end of the list. |
testSpec | test specification to be added. |
void isys::CTestSpecification::addDerivedTestSpec | ( | int | idx, |
CTestSpecificationSPtr | testSpec ) |
Adds given test specification to the list of derived specifications at the given index.
Parent of the added test specification is NOT modified! Use this method when adding test specification to container test spec, not to parent in the model. For example, if user selects several distinct test specs in tree, a container test spec can be used to group all selected test specs together and then for example execute them. However, their parents MUST NOT be modified, because they are still members of the test tree!
idx | advice where to put test spec in the derived test spec list If -1 or out of range, the test spec is added to the end of the list. |
testSpec | test specification to add. |
void isys::CTestSpecification::assignStubs | ( | const CTestSpecificationSPtr & | src | ) |
This method copies stubs from src to this object.
Original stubs are removed.
void isys::CTestSpecification::assignTestPoints | ( | const CTestSpecificationSPtr & | src | ) |
This method copies test points from src to this object.
Original test points are removed.
void isys::CTestSpecification::assignUserStubs | ( | const CTestSpecificationSPtr & | src | ) |
This method copies stubs from src to this object.
Original stubs are removed.
|
static |
Casts the given object to this class.
Returns NULL if input is NULL.
IllegalArgumentException | if input object is not instance of this class. |
void isys::CTestSpecification::clearEmptySections | ( | ) |
This method releases all sections, which contain no data (only empty strings).
It can save some memory this way - it exists for optimization purposes, not functionality.
void isys::CTestSpecification::clearMergedFilterInfo | ( | bool | isClearRecursively | ) |
For optimization reasons test specification stores merged info during filtering.
However, it is not automatically reset on test spec change (for example when setTestId() is called), so this method must be explicitly called before running tests with filtering. Otherwise stale data in cache will corrupt filtering.
|
override |
Creates an empty instance of this class.
parent | must be of instance CTestSpecification, since other classes can not be parents of CTestSpecification. |
|
override |
Deletes the given derived test spec.
Returns index of deleted test spec, if the spec was found and deleted, -1 if it was not found.
CTestSpecificationSPtr isys::CTestSpecification::findDerivedTestSpec | ( | const std::string & | testId, |
int | recursiveLevel ) |
This method returns the first derived test specification with the given ID.
It does not check if there are other derived test specs with the given ID.
testId | |
recursiveLevel | defines how deep in hierarchy the search should go. Usually it has value 0, which means only derived test specs of the containerTestSpec, or -1, which means infinite depth. |
int isys::CTestSpecification::findDerivedTestSpec | ( | CTestSpecificationSPtr & | testSpec | ) |
Returns index of the given test specification, or -1 if not found.
Pointer equality is checked, only the first level is searched.
std::string isys::CTestSpecification::getBaseId | ( | ) |
Returns id of the parent.
This tag is used only when test specifications are specified in the source code file, and is ignored otherwise.
|
override |
If section is merged, returns cached merged test spec., which was set with setCachedMergedTestSpec(), else null is returned.
Needed for optimization purposes.
|
overridevirtual |
Always returns this.
This method is overridden from CTestBase, and is used by other aggregated classes to find the container test spec, which is this.
isys::CTestAnalyzerCoverageSPtr isys::CTestSpecification::getCoverage | ( | bool | isConst | ) |
CTestSpecificationSPtr isys::CTestSpecification::getDerivedTestSpec | ( | int | idx | ) |
Returns derived test spec at the given index.
The returned test specification contains only its own data, no data from base test specification is inherited with this call. To get a test specification with inherited data, which can be executed, call method merge()
on the returned test specification object.
idx | index to derived test specification. It should be and less than the value returned by getNoOfDerivedSpecs() , and >= 0. |
IndexOutOfBoundsException | if index is not valid. |
void isys::CTestSpecification::getExpectedResults | ( | iconnect::StrVector & | expectedResults | ) |
Returns expected values, specified as a list of expressions.
expectedResults | StrVector to receive expected values |
|
override |
Return true, if there is no data in test specification.
Returns test id as specified in tag id.
iconnect::StrVector isys::CTestSpecification::getInitKeys | ( | ) |
Returns vector with names of variables to be initialized.
The vector contains variables in the same order in which they were inserted into internal map, and this is also the order that should be used for initialization. See also getInitValues().
void isys::CTestSpecification::getInitMap | ( | iconnect::StrStrMap & | initMap | ) |
Returns initialization assignments of local variables.
Note: The order of assignments is not preserved! Use this method to get values of the known variables, but not to modify it and then use it for setting of assignments.
initMap | object to receive mapping data |
CTestFunctionSPtr isys::CTestSpecification::getInitTargetFunction | ( | bool | isConst | ) |
Returns specification for script function to be called before any test initialization is done.
Use it to initialize target before test.
void isys::CTestSpecification::getInitValues | ( | iconnect::StrVector & | values | ) |
Returns vector with values of variables to be initialized.
Values are returned in the order which matches keys returned by getInitKeys(). See also getInitKeys().
void isys::CTestSpecification::getLocalVariables | ( | iconnect::StrStrMap & | localVars | ) |
Returns local variables specified as a map of [var name, var type]
pairs.
localVars | map to receive local variables |
int isys::CTestSpecification::getNoOfTests | ( | bool | isSkipAbstractTests | ) |
Returns the number of tests in this test specification - counts this specification and all derived tests.
isSkipAbstractTests | if true, abstract tests are not counted (tests with 'run' tag set to false) - the number of runnable tests is returned. |
iconnect::StrVector isys::CTestSpecification::getOptionKeys | ( | ) |
Returns names of winIDEA options to be set.
See also getOptionValues().
void isys::CTestSpecification::getOptionValues | ( | iconnect::StrVector & | values | ) |
Returns values of winIDEA options to be set.
They are in the same order as keys returned by getOptionKeys().
isys::CTestAnalyzerProfilerSPtr isys::CTestSpecification::getProfiler | ( | bool | isConst | ) |
CTestFunctionSPtr isys::CTestSpecification::getRestoreTargetFunction | ( | bool | isConst | ) |
Returns specification for script function to be called after test environment on the stack is destroyed.
Use it to restore target state after test.
iconnect::ETristate isys::CTestSpecification::getRunFlag | ( | ) |
Returns run flag.
If value is E_TRUE or E_DEFAULT, test specification should be executed - it is not used just as a base class.
int isys::CTestSpecification::getSourceLineNumber | ( | ) |
Returns number of the line in file, where this test spec is defined, or -1 if not set.
This value is not valid, after test specification is moved to other location in test tree or pasted from clipboard. In such cases it shows the source, where the test specification WILL be saved.
std::string isys::CTestSpecification::getTestId | ( | ) |
Deprecated since Jan 2016.
Use getId() instead.
int isys::CTestSpecification::getTestPointIdx | ( | const std::string & | testPointId | ) |
isys::CTestBaseListSPtr isys::CTestSpecification::getTestPoints | ( | bool | isConst | ) |
Returns reference to list of all test point specifications.
New test points can be added by adding them to the returned vector.
int isys::CTestSpecification::getTestTimeout | ( | ) |
Returns timeout (in milliseconds), after which test execution is terminated.
Value 0 means infinite timeout. If this value is not specified, this method returns -1 (global timeout setting will be used).
isys::CTestAnalyzerTraceSPtr isys::CTestSpecification::getTrace | ( | bool | isConst | ) |
CTestBaseListSPtr isys::CTestSpecification::getUserStubs | ( | bool | isConst | ) |
Returns reference to list of all user stub specifications.
New stubs can be added by adding them to the returned vector.
std::string isys::CTestSpecification::getWarnings | ( | ) |
If there were any warnings detected during parsing, this method returns non-empty string with description of warnings.
It is recommended to call this method always after parsing.
bool isys::CTestSpecification::isEmptyExceptDerived | ( | ) |
Returns true, if test spec has no data, except derived test specs.
This is used in GUI, which may hide the root test spec in such case.
bool isys::CTestSpecification::isInheritSection | ( | CTestSpecification::SectionIds | sectionId | ) |
This method returns true, if isSectionMerged() returns true, AND this section is marked as inherited in the 'imports' section.
Rules for inheritance:
isInherit | definedInBase | definedInDerived | isInheritSection | isEditable |
---|---|---|---|---|
0 | 0 | 0 | 0 | 1 |
0 | 0 | 1 | 0 | 1 |
0 | 1 | 0 | 0 | 1 |
0 | 1 | 1 | 0 | 1 |
1 | 0 | 0 | 0 | 1 |
1 | 0 | 1 | 0 | 1 |
1 | 1 | 0 | 1 | 0 |
1 | 1 | 1 | 0 | 1 |
from imports | isSectionMerged() |
bool isys::CTestSpecification::isSectionMerged | ( | SectionIds | sectionId | ) |
This method returns true, if the section is defined in parent test spec, but not in this test spec.
This rule is processed recursively for all parents. If a parent with non-empty section is found, this method returns true. This method does not take 'imports' section into account - see method isInheritSection().
|
override |
Always returns true.
Needed because type info is lost with SWIG.
|
static |
Loads test specification from file.
fileName | name of the file to load. |
filePos | offset in file to start reading from. |
CTestSpecificationSPtr isys::CTestSpecification::merge | ( | ) |
This method merges all parent test specifications with this one.
All sections, which are defined in parent test specifications and not in this test spec., are copied to the returned test specification. Original test specifications are not modified.
|
static |
Parses test specification in YAML format and returns new object containing the given information.
This method is implemented for access from SWIG wrappers, which are not aware of ITestParserEventReceiver. C++ apps should use more generic parseYAML() method.
yamlSpec | test spec. in YAML format |
int isys::CTestSpecification::removeStub | ( | const std::string & | functionName | ) |
Removes stub with the given function name.
Returns stub index in a list, if stub was removed, -1 if the stub did not exist.
int isys::CTestSpecification::removeUserStub | ( | const std::string & | functionName | ) |
Removes user stub with the given function name.
Returns stub index in a list, if stub was removed, -1 if the stub did not exist.
void isys::CTestSpecification::save | ( | const std::string & | fileName, |
bool | isAppend = false ) |
Writes test spec to the given file.
fileName | name of the file to write specification to |
isAppend | if true, test spec is appended to the given file. This is useful, if test spec must be inserted into the file - caller copies the first part of the file, calls this method, and finally copies the rest of the file. |
void isys::CTestSpecification::setBaseId | ( | const std::string & | testId | ) |
Sets parent id.
void isys::CTestSpecification::setCachedMergedTestSpec | ( | CTestSpecificationSPtr & | mergedTestSpec | ) |
Caches merged test spec.
to be used in subsequent calls. Needed for optimization purposes.
void isys::CTestSpecification::setExpectedResults | ( | const iconnect::StrVector & | expectedResults | ) |
expectedResults | vector of expected results. |
void isys::CTestSpecification::setIdeOptions | ( | const std::string & | yamlSpec | ) |
Sets IDE options.
yamlSpec | map of option_path: option_value pairs in YAML format. |
void isys::CTestSpecification::setInitValues | ( | const std::string & | yamlSpec | ) |
Sets initialization values of variables used in test.
yamlSpec | map of var_name: init_value pairs in YAML format. |
void isys::CTestSpecification::setLocalVariables | ( | const std::string & | yamlSpec | ) |
Sets declarations of local variables used in test.
yamlSpec | map of var_name: var_type pairs in YAML format. |
|
override |
Always sets mapping style to BLOCK.
Because of YAML comments FLOW style is not allowed for instances of this class.
void isys::CTestSpecification::setTags | ( | const std::string & | tags | ) |
void isys::CTestSpecification::setTestTimeout | ( | int | timeout | ) |
Sets timeout (in milliseconds), after which test execution is terminated.
Value 0 means infinite timeout, value -1 means that timeout is not specified, and that global timeout setting will be used.