winIDEA SDK
isys::CTestResult Class Reference

Description

This class stores results of test case run.

Normally it is not intended to be instantiated by clients - call isys::CTestCase::getTestResult() or similar method in the scripting language wrapper to get test results. However, if you'd like to create testIDE-like reports with custom scripts, feel free to use it.

For result analysis the simple method used in itest_sample.py is enough in most cases:




Python example.

#include <CTestResult.h>

Inherits isys::CTestResultBase.

Public Types

enum  ETestResultSection { E_SECTION_RESULT_COMMENT , E_SECTION_DEFAULT_DOWNLOAD_FILE , E_SECTION_STUB_RESULTS , E_SECTION_TEST_POINT_RESULTS , E_SECTION_STACK_USAGE_RESULTS , E_SECTION_TARGET_EXCEPTION , E_SECTION_PRE_CONDITION , E_SECTION_ASSERT , E_SECTION_LOG , E_SECTION_DRY_RUN_ASSIGNMENTS , E_SECTION_DIAGRAMS , E_SECTION_SCRIPT_ERRORS , E_SECTION_SCRIPT_OUTPUT }
 Test result sections. More...
 

Public Member Functions

std::string getResultComment () override
 Returns comment, which describes specific test run. More...
 
std::string getDefaultDownloadFile ()
 Returns default download file name. More...
 
std::string getTestId () const
 Returns the testId.
 
std::string getFunction () const
 Returns the name of the function under test.
 
isys::CTestSpecificationSPtr getTestSpecification ()
 Returns test specification, which produced this result. More...
 
std::string getProfilerExportFileName ()
 Returns name of the file, where profiler data was exported - this is real file name, without host variables (they were replaced with values before test execution and saved in this class).
 
bool isError () override
 Returns true if any of possible errors occurred - expressions, profiler, coverage, exception, ...
 
bool isException () override
 Returns true, if an exception was thrown.
 
std::string getExceptionString () override
 If isException() returns true, this method returns the message of the exception.
 
bool isTargetException ()
 Returns true, if exception was thrown by function on the target.
 
bool isExpressionError ()
 Returns true, if target values after test run don't match expected values given in test specification (section 'expected').
 
bool isPreConditionError ()
 Returns true, if conditions verified before test failed.
 
bool isTargetExceptionError ()
 Returns true, if exception was thrown on target, but it is not expected as test result, or it is expected as test result, but it was not thrown on the target.
 
bool isCodeCoverageError ()
 Returns true, if coverage results don't match the test specification requirements.
 
bool isProfilerCodeError ()
 Returns true, if profiler code results don't match the test specification requirements.
 
bool isProfilerDataError ()
 Returns true, if profiler data results don't match the test specification requirements.
 
bool isScriptError () override
 Returns true, if there was error when executing script functions.
 
bool isScriptError (const std::string &scriptFunctionType) override
 Returns true, if there was error when executing the given script function.
 
bool isTestPointError ()
 Returns true, if there was error in test points.
 
bool isStubError ()
 Returns true, if there was error in stub.
 
bool isStackUsageError () override
 Returns true, if there was error in stack usage.
 
std::string getScriptError (const std::string &scriptFunctionType) override
 Returns string returned by the given script function. More...
 
std::string getScriptOutput (const std::string &scriptFunctionType) override
 Returns everything printed to std out by script function.
 
CTestBaseListSPtr getPreConditionResults (bool isConst)
 Returns list of precondition evaluations.
 
CTestBaseListSPtr getAssertResults (bool isConst)
 Returns list of CTestExprResult -s, one item per assert expression.
 
CLogResultSPtr getLogResult (bool isConst)
 Returns object containing logged values.
 
void getCoverageResults (isys::StrCoverageTestResultsMap &resultMap) const
 Returns all coverage results.
 
void getCoverageResultsWithError (isys::StrCoverageTestResultsMap &resultMap) const
 Returns only those coverage results, which do match expected values.
 
isys::CProfilerTestResultSPtr getProfilerCodeResult (const std::string areaName)
 Returns profiler code result if exists, NULL otherwise.
 
void getProfilerCodeResults (isys::StrProfilerTestResultsMap &resultMap)
 Returns all profiler code results.
 
isys::CProfilerTestResultSPtr getProfilerDataResult (const std::string areaName)
 Returns profiler data result without value set if exists, NULL otherwise.
 
void getProfilerDataResults (isys::StrProfilerTestResultsMap &resultMap)
 Returns all profiler data results.
 
void serialize (const isys::IEmitterSPtr &emitter, const isys::CTestReportConfigSPtr &reportConfig)
 Writes result to destination stream, which is usually associated with file. More...
 
void serializeErrorsOnly (const isys::IEmitterSPtr &emitter, const isys::CTestReportConfigSPtr &reportConfig)
 Writes errors to destination stream, which is usually associated with file. More...
 
std::string toString ()
 Returns object's data as YAML string. More...
 
std::string toUIString ()
 Returns string readable also as pure text, only errors are included.
 
void setTargetException (bool isTargetException)
 Set to true, if exception on target occurred during test. More...
 
void setResultComment (const std::string &resultComment)
 Set arbitrary text to appear in test report, for example test description or purpose.
 
void setLogResult (const CLogResultSPtr &logResult)
 Sets log result.
 
void addExprResult (CTestResult::ETestResultSection section, CTestExprResultSPtr &result)
 Adds result of evaluated test expression. More...
 
void addStubResult (CTestPointResultSPtr &result)
 Adds stub result.
 
void addTestPointResult (CTestPointResultSPtr &result)
 Adds test point result.
 
void setStackUsageResult (CStackUsageResultSPtr stackUsageResult)
 Sets Stack usage result.
 
void setTargetExceptionStr (const std::string &targetException)
 Sets description of target exception. More...
 
void appendScriptError (const std::string &scriptFunctionType, const std::string &errorDesc) override
 Appends error message of script function.
 
void appendScriptOutput (const std::string &scriptFunctionType, const std::string &outStr) override
 Appends stdout of script function.
 

Member Enumeration Documentation

◆ ETestResultSection

Test result sections.

Enumerator
E_SECTION_RESULT_COMMENT 

comment user enters in tesIDEA to be saved to report.

It should describe conditions for particular test run.

Member Function Documentation

◆ addExprResult()

void isys::CTestResult::addExprResult ( CTestResult::ETestResultSection  section,
CTestExprResultSPtr &  result 
)

Adds result of evaluated test expression.

Parameters
sectionshould be CTestResult::E_SECTION_PRE_CONDITION, or CTestResult::E_SECTION_ASSERT, if expression is evaluated before or after test respectively.
resultresult to be added.

◆ getDefaultDownloadFile()

std::string isys::CTestResult::getDefaultDownloadFile ( )

Returns default download file name.

It is set only when profiler was run during test.

◆ getResultComment()

std::string isys::CTestResult::getResultComment ( )
override

Returns comment, which describes specific test run.

This value is typically entered by user after test run and before saving test report.

◆ getScriptError()

std::string isys::CTestResult::getScriptError ( const std::string &  scriptFunctionType)
override

Returns string returned by the given script function.

If there was no error, an empty string is returned.

◆ getTestSpecification()

isys::CTestSpecificationSPtr isys::CTestResult::getTestSpecification ( )

Returns test specification, which produced this result.

Usually this is the merged test specification.

◆ serialize()

void isys::CTestResult::serialize ( const isys::IEmitterSPtr emitter,
const isys::CTestReportConfigSPtr reportConfig 
)

Writes result to destination stream, which is usually associated with file.

Parameters
emitterdestination object for serialized data
reportConfigreport configuration. If set to NULL, default configuration is used. If CTestReportConfig::setReportContents(RCONFIG_ERRORS_ONLY) is called, this call is identical to call serializeErrorsOnly() below.

◆ serializeErrorsOnly()

void isys::CTestResult::serializeErrorsOnly ( const isys::IEmitterSPtr emitter,
const isys::CTestReportConfigSPtr reportConfig 
)

Writes errors to destination stream, which is usually associated with file.

Parameters
emitterdestination object for serialized data
reportConfigreport configuration. If set to NULL, default configuration is used.

◆ setTargetException()

void isys::CTestResult::setTargetException ( bool  isTargetException)

Set to true, if exception on target occurred during test.

See also
setTargetExceptionStr

◆ setTargetExceptionStr()

void isys::CTestResult::setTargetExceptionStr ( const std::string &  targetException)

Sets description of target exception.

See also
setTargetException

◆ toString()

std::string isys::CTestResult::toString ( )

Returns object's data as YAML string.

This method is intended for debugging purposes only, do not parse the returned data!