winIDEA SDK
python.exports.isystem.itest.PTestCase Class Reference

Description

This class is a wrapper of 'ic.CTestCase' class. It
has the same functionality, but adapted to Python. The only
difference is in handling of callbacks specified in test
specification (stubs, 'initFunc', 'endFunc', ...). While
'ic.CTestCase' requires C++ implementation of these
methods, this class can call methods defined in Python.  All
callback methods must be defined in object passed as parameter
'extensionObj' to methods in this class.

Parameters:
icConnection - instance of CMulticoreConnectionMgr. For backward
               compatibility also instance of ICFactory or
               ConnectionMgr is accepted, but some functionality
               does not work in that case.
               ICFactory and ConnectionMgr are deprecated
               since 9.12.188, 2014-09-05

Public Member Functions

def setISysDirs (self, isysDirs)
 
def initEnvironment (self, testEnvConfig, dbg, ideCtrl, targetStopTimeout)
 
def executeInitSequence (self, envConfig, multicoreCMgr, targetStopTimeout, extensionObj, monitor)
 
def restoreEnvironment (self, testEnvConfig, dbg=None, ideCtrl=None, targetStopTimeout=0)
 
def restoreState (self)
 
def setTestCaseInitConfig (self, testCaseInitConfig)
 
def runTests (self, testSpec, extensionObj=None, monitor=None, testFilter=None, isDebugMode=False, envConfig=None, testBench=None)
 
def itest (self, testSpec, extensionObj, isDebugMode=False, hostVars=None, filterCtrl=None)
 
def runDerivedTests (self, testSpec, extensionObj=None, monitor=None, testFilter=None, isDebugMode=False, envConfig=None, testBench=None)
 
def countExecutableTests (self, testSpec, filterCtrl, testFilter, extensionObject)
 
def loadTestSpec (self, fileName, filePos=0)
 
def getCoverageResults (self)
 
def getProfilerCodeResults (self)
 
def getProfilerDataResults (self)
 
ic.CTestReportContainer getTestResultsContainer (self)
 
def getTestResults (self)
 
def saveTestResultsAsJUnit (self, fileName, testSuiteName)
 
def saveTestResultsAsJUnitStart (self, of, testSuitesName, tests, errors, failures)
 
def saveTestResultsAsJUnitEnd (self, of)
 
def saveTestResultsAsJUnitForTestSuite (self, of, testSuiteName, reportStats=None)
 
def getReportStatistics (self)
 
def reset (self)
 
def execCustomScript (self, extensionObject, extMethod, reportConfig)
 

Member Function Documentation

◆ countExecutableTests()

def python.exports.isystem.itest.PTestCase.countExecutableTests (   self,
  testSpec,
  filterCtrl,
  testFilter,
  extensionObject 
)
This method returns the number of executable tests including
the given testSpec and all its derived test
specifications. Test specification is executable, if its 'run'
flag is set to true, and it passes the given 'testFilter'.

Parameters:
  testSpec: instance of ic.CTestSpecification

  testFilter: instance of ic.CTestFilter

◆ execCustomScript()

def python.exports.isystem.itest.PTestCase.execCustomScript (   self,
  extensionObject,
  extMethod,
  reportConfig 
)
 This method executes the given extension method. 

◆ executeInitSequence()

def python.exports.isystem.itest.PTestCase.executeInitSequence (   self,
  envConfig,
  multicoreCMgr,
  targetStopTimeout,
  extensionObj,
  monitor 
)
Initializes target, according to settings in envConfig.

Parameters:

envConfig: instance of ic.CTestEnvironmentConfig
multicoreCMgr: CMulticoreConnectionMgr, may not be None
targetStopTimeout: timeout in milliseconds
extensionObj: object with script extension methods. May be None
              only if init sequence contains no script actions.
monitor: object to provide feedback to the user. May be set to None.

◆ getCoverageResults()

def python.exports.isystem.itest.PTestCase.getCoverageResults (   self)
Deprecated - call getTestResults() and then getCoverageResults() on
returned CTestResult. This method returns results ony for the first test.

Returns coverage data recorded during test run. It returns a
mapping of < functionName, CCoverageStatistic >

◆ getProfilerCodeResults()

def python.exports.isystem.itest.PTestCase.getProfilerCodeResults (   self)
Deprecated - call getTestResults() and then getProfilerCodeResult() on
returned CTestResult.

Returns function profiler results recorded during test run. It returns a
mapping of < functionName, CProfilerStatistic > for function profiling.

◆ getProfilerDataResults()

def python.exports.isystem.itest.PTestCase.getProfilerDataResults (   self)
Deprecated - call getTestResults() and then getProfilerDataResult() on
returned CTestResult.

Returns data profiler results recorded during test run. It returns a
mapping of < variableName, list of CProfilerStatistic > for data profiling.
Each CProfilerStatistic from the list contains profiler statistic for
one variable value.

◆ getReportStatistics()

def python.exports.isystem.itest.PTestCase.getReportStatistics (   self)
Returns instance of CTestReportStatistic() from results of last run.

◆ getTestResults()

def python.exports.isystem.itest.PTestCase.getTestResults (   self)
@deprecated since 9.12.266. Call getTestResultsContainer() instead,
because it also provides group results, while this method returns
only test case results.

This method returns test results as a list of isys::CTestResult classes.
The number of results depends on the number of tests run - each derived
test adds one result item. Each call to methods runDerivedTests() or
itest() clears previous results.

Note: This method copies internal data to
isystem.connect.TestResultsVector(), so it is recommended to
keep the object instead of repeatedly calling this method.

◆ getTestResultsContainer()

ic.CTestReportContainer python.exports.isystem.itest.PTestCase.getTestResultsContainer (   self)
Returns instance of `ic.CTestReportContainer`, containing test case results,
and group results.

◆ initEnvironment()

def python.exports.isystem.itest.PTestCase.initEnvironment (   self,
  testEnvConfig,
  dbg,
  ideCtrl,
  targetStopTimeout 
)
Deprecated since 9.12.188, 2014-09-05, call executeInitSequence() instead.

Initializes target, according to settings in testEnvConfig.

Parameters:

testEnvConfig: instance of ic.CTestEnvironmentConfig

◆ itest()

def python.exports.isystem.itest.PTestCase.itest (   self,
  testSpec,
  extensionObj,
  isDebugMode = False,
  hostVars = None,
  filterCtrl = None 
)
This method executes unit test according to the given test
specification. Only the given test specification is executed
- no merging is performed and derived test specifications are NOT
executed.
If you want to execute also derived tests, it is more effectively
to call method runTests(), since some optimization may be performed
in unit tests.

Parameters:

testSpec: test specification as string in YAML format or instance of
                   ic.CTestSpecification. See User's guide for
                   detailed description of YAML syntax.

extensionObj: object, with functions, which are specified in test
               specification sections 'initFunc', 'endFunc', 'initTargetFunc',
               'restoreTargetFunc', and 'stubs.script'.
               If test specification does not contain these
               sections, this parameter may be set to None.

hostVars: Should be None or instance of CTestHostVars. If test case contains
          host variables, they should be defined in this object.

isDebugMode: when True, cleanup is not performed immediately after error, but
             waits for the user to press ENTER. This way we can see winIDEA
             state in case of an error during test, for example when it stops
             on some forgotten breakpoint, or when we stop the target because
             it is inside never ending or long running loop.

filterCtrl: may be None if coverage merge (section Analyzer / Coverage)
            is not used in the given test case. If coverage merge is
            specified, then this parameter must not be None and symbols must be
            initialized. Example:

            testBench = ic.CTestBench()

            # If running multicore tests, set core IDs:
            #   testEnv = testBench.getTestEnvironmentConfig(True)
            #   testEnv.setTagValue(ic.CTestEnvironmentConfig.E_SECTION_CORE_IDS,
            #                       '[core-0, core1]')

            testBench.refreshSymbolsAndGroupsIfEmpty(mccMgr, None)
            filterCtrl = testBench.getFilterController()

◆ loadTestSpec()

def python.exports.isystem.itest.PTestCase.loadTestSpec (   self,
  fileName,
  filePos = 0 
)
Loads test bench data file.

Parameters:

   fileName: name of the file to load

   filePos: offset in file to start loading from

◆ reset()

def python.exports.isystem.itest.PTestCase.reset (   self)
This method resets the test subsystem in winIDEA. Use it, when
invalid state is reported when calling the itest() method.

◆ restoreEnvironment()

def python.exports.isystem.itest.PTestCase.restoreEnvironment (   self,
  testEnvConfig,
  dbg = None,
  ideCtrl = None,
  targetStopTimeout = 0 
)
Deprecated since 9.12.188, 2014-09-05. Use restoreState() instead.

Restores target after test, according to settings in testEnvConfig.

Parameters:

testEnvConfig: instance of ic.CTestEnvironmentConfig
Other parameters are ignored and deprecated - will be removed in future
versions.

◆ restoreState()

def python.exports.isystem.itest.PTestCase.restoreState (   self)
Restores internal variables after test

◆ runDerivedTests()

def python.exports.isystem.itest.PTestCase.runDerivedTests (   self,
  testSpec,
  extensionObj = None,
  monitor = None,
  testFilter = None,
  isDebugMode = False,
  envConfig = None,
  testBench = None 
)
Deprecated! Clients should use method runTests() instead!

◆ runTests()

def python.exports.isystem.itest.PTestCase.runTests (   self,
  testSpec,
  extensionObj = None,
  monitor = None,
  testFilter = None,
  isDebugMode = False,
  envConfig = None,
  testBench = None 
)
This method runs the given test specification and derived test
specifications.

Parameters:

testSpec: test specification as string in YAML format or instance of
                   ic.CTestSpecification. See User's guide for
                   detailed description of YAML syntax.

extensionObj: object, with functions, which are specified in test
               specification sections 'initFunc', 'endFunc', 'initTargetFunc',
               'restoreTargetFunc', and 'stubs.script'.
               If test specification does not contain these
               sections, this parameter may be set to None.

monitor: object to be notified about test progress. It has to implement
         the following methods:
           isCanceled(self) should return \\c True if you want to cancel tests in
                        progress, \\c False otherwise
           subTask(self, string) this method is called when the test starts. Parameter
                           contains test ID and function name as string.
           worked(self, int) this method is called when the test completes. Parameter
                       is always one, which means one test has completed.
         Optional method:
           setTestInfo(self, **kwargs) parameter 'testCase' contains current
                                       CTestSpecification object


isDebugMode: when True, cleanup is not performed immediately after error, but
             waits for the user to press ENTER. This way we can see winIDEA
             state in case of an error during test, for example when it stops
             on some forgotten breakpoint, or when we stop the target because
             it is inside never ending or long running loop.

testFilter: instance of class CTestFilter, if we want to execute only subset
            of the given tests. If None, all tests are executed. If specified,
            make sure to call \c testSpec.clearMergedFilterInfo(True) before
            calling this method, otherwise stale cache filtering data might
            cause strange behavior of filter.
envConfig: instance of class CTestEnvironmentConfig. Should never be null.
           For backward compatibility null is tolerated, but interrupts
           on target are not disabled in that case!

◆ saveTestResultsAsJUnit()

def python.exports.isystem.itest.PTestCase.saveTestResultsAsJUnit (   self,
  fileName,
  testSuiteName 
)
This method saves test results in Junit format, so that it can be parsed
by Jenkins/Hudson. This method creates file with one test suite.

For details about the format see:
https://stackoverflow.com/questions/4922867/junit-xml-format-specification-that-hudson-supports

XSD:
https://svn.jenkins-ci.org/trunk/hudson/dtkit/dtkit-format/dtkit-junit-model/src/main/resources/com/thalesgroup/dtkit/junit/model/xsd/junit-4.xsd

Instead of class name function name is written, and test case ID is used
as contents of 'name' attribute.

Parameters:

fileName - name of file to save report to
testSuiteName - name of test suite which is used for attribute name:
                '<testsuite name="' + testSuiteName + '" ...

Example:
<testsuites tests="3" errors="0" failures="0">
  <testsuite tests="3" errors="0" failures="0">
    <testcase classname="add_int" name="test-0"/>
    <testcase classname="add_int" name="test-1"
      <error type="exception"/>Invalid value!</error>
    </testcase>
    <testcase classname="max_int" name="test-2">
      <failure type="expression"/>
    </testcase>
  </testsuite>
</testsuites>

◆ saveTestResultsAsJUnitEnd()

def python.exports.isystem.itest.PTestCase.saveTestResultsAsJUnitEnd (   self,
  of 
)
This method adds the last tag to XML file in Jenkins/Hudson format.
See method saveTestResultsAsJUnitStart() for details.

◆ saveTestResultsAsJUnitForTestSuite()

def python.exports.isystem.itest.PTestCase.saveTestResultsAsJUnitForTestSuite (   self,
  of,
  testSuiteName,
  reportStats = None 
)
This method saves test results in Junit format, so that it can be parsed
by Jenkins/Hudson for one test suite. Typical usage:

    saveTestResultsAsJUnitStart(...)
    saveTestResultsAsJUnitForTestSuite(...)
    saveTestResultsAsJUnitEnd()

See method saveTestResultsAsJUnitStart() for details.

◆ saveTestResultsAsJUnitStart()

def python.exports.isystem.itest.PTestCase.saveTestResultsAsJUnitStart (   self,
  of,
  testSuitesName,
  tests,
  errors,
  failures 
)
This method saves test results in Junit format, so that it can be parsed
by Jenkins/Hudson. Use this method when you want to save several test sessions
into one file. Typical usage:

    saveTestResultsAsJUnitStart(...)
    saveTestResultsAsJUnitForTestSuite(...)
    saveTestResultsAsJUnitEnd()


Parameters:
of - opened file stream
testSuitesName - values for the 'name' attribute of tags 'testsuites' and
                 'testsuite'
tests - number of all tests in test suite
errors - number of errors
filures - number of failures

For details about format see method saveTestResultsAsJUnit().

◆ setISysDirs()

def python.exports.isystem.itest.PTestCase.setISysDirs (   self,
  isysDirs 
)
 Sets directories used to access files. 

◆ setTestCaseInitConfig()

def python.exports.isystem.itest.PTestCase.setTestCaseInitConfig (   self,
  testCaseInitConfig 
)
Call this method with instance of CTestCaseTargetInitConfig
(see class CTestBench), if you want to initialize target
before each test case.