winIDEA SDK
Loading...
Searching...
No Matches
python.exports.isystem.itest.PTestCase Class Reference

Public Member Functions

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

Protected Member Functions

 _callCTestFunction (self, testSpec, hostVars, funcType, cTestFunction, extensionObj)
 _callFunctionUnderTest (self, testSpec, testCaseCtrl, coverageCtrl, stubs, extensionObj)
 _callScriptFunction (self, _isys_testSpec, functionName, paramsStrVector, extensionObj, funcType)
 _callStubs (self, testSpec, testCaseCtrl, stubs, extensionObj)
 _createTestSpecification (self, yamlTestSpec)
 _isTestExecutable (self, testSpec, filterCtrl, testFilter, extensionObject, isTestSpecMerged)

Detailed 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:
@param 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

Member Function Documentation

◆ _callCTestFunction()

python.exports.isystem.itest.PTestCase._callCTestFunction ( self,
testSpec,
hostVars,
funcType,
cTestFunction,
extensionObj )
protected
Calls script method as defined in 'CTestFunction' object.


Parameters:

cTestFunction: object of type CTestFunction

extensionObj: object with method of the same name as returned
                         by 'cTestFunction.getName()'.

◆ _callFunctionUnderTest()

python.exports.isystem.itest.PTestCase._callFunctionUnderTest ( self,
testSpec,
testCaseCtrl,
coverageCtrl,
stubs,
extensionObj )
protected
Runs function to be tested.

All configuration must be done before calling this method,
including parameters, variables and stubs. If stubs are hit,
they are handled by this method.

This method returns, when the execution stops for any other
reason than stub.  It is recommended to check the status with
'testCaseCtrl.getStatus()' after this method returns to make
sure that the test ended successfully.


Parameters:

testCaseCtrl: object of type CTestCaseController

stubs: ic.StrVector containing all stubs

extensionObj: object with methods of the same name as
                         returned by 'stub.getStubFunction()'
                         for all stubs

◆ _callScriptFunction()

python.exports.isystem.itest.PTestCase._callScriptFunction ( self,
_isys_testSpec,
functionName,
paramsStrVector,
extensionObj,
funcType )
protected
Calls custom script funciton.

IMPORTANT: Parameter name '_isys_testSpec' is defined in
'Script.java', and it is very important to use the same string
here, because it may be specified in parameter
'paramsStrVector'!

◆ _callStubs()

python.exports.isystem.itest.PTestCase._callStubs ( self,
testSpec,
testCaseCtrl,
stubs,
extensionObj )
protected
If current test status == IConnectTest.stateStub, this method
finds the stub declaration from test specification. Then it
sets data and calls stub methods in 'extensionObj'.


Parameters:

testCaseCtrl: object of type CTestCaseController

stubs: ic.StrVector of all stubs

extensionObj: object with methods of the same name as
                         returned by 'stub.getStubFunction()'
                         for all stubs

◆ _createTestSpecification()

python.exports.isystem.itest.PTestCase._createTestSpecification ( self,
yamlTestSpec )
protected
Parses test specification.


Parameters:

yamlTestSpec: test specification in YAML format. See User's
                      guide for detailed description

Returns: instance of 'ic.CTestSpecification()' filled with
                 data from 'yamlTestSpec'

◆ _isTestExecutable()

python.exports.isystem.itest.PTestCase._isTestExecutable ( self,
testSpec,
filterCtrl,
testFilter,
extensionObject,
isTestSpecMerged )
protected
Returns true, if the test is executable according to the 'run'
flag in test specification and filter settings.

Parameters:

testSpec: instance of CTestSpecification

testFilter: instance of CTestFilter or None

◆ countExecutableTests()

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()

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

◆ executeInitSequence()

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()

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()

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()

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()

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

◆ getTestResults()

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()

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()

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()

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()

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()

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()

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

◆ runDerivedTests()

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()

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:
           is_canceled(self) should return ``True`` if you want to cancel tests in
                        progress, ``False`` otherwise
           sub_task(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:
           set_test_info(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 ``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()

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()

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()

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()

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()

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

◆ setTestCaseInitConfig()

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.