polyspace.test.TestSuiteResult Class
Namespace: polyspace.test
Description
This Python® class contains test results for a specific C/C++ test suite.
Creation
Description
testSuiteResult = loads the results of test suite number testResults.TestSuiteResults[testSuiteIndex]testSuiteIndex:
From a
polyspace.test.TestResultsobjecttestResults.To a
polyspace.test.TestSuiteResultobjecttestSuiteResult.
Here, testSuiteIndex is the index of the test suite specified as an integer starting from 0.
Properties
The properties, PassedAssessmentCount, FailedAssessmentCount, AssessmentResults, Events, Messages, PassedAssessmentResults, FailedAssessmentResults and Exceptions are associated with assessments and other events outside a test suite configuration or test. In most cases, you do not require these properties. The
remaining properties are described below.
Name of test suite.
Testing framework, specified as a string with one of these values:
"pstunit"for tests authored in the Polyspace® Platform user interface or using the C/C++ xUnit API."external"for tests authored using another framework.
Overall execution status of the test suite, specified as a polyspace.test.StatusInfo object with the following properties:
| Property | Values | Description |
|---|---|---|
Failed | True or False | The value of this property is In all other cases, the value is
|
Incomplete | True or False | The value of this property is In all other cases, the value is |
File containing suite definition.
Line number where suite definition begins. This is the line containing the PST_SUITE or PST_SUITE_CONFIG macro (depending on whether your test suite has a configuration or not).
Timing of suite or test execution and timestamp of execution, specified as a polyspace.test.TimingInfo object with the following properties:
| Property | Value | Description |
|---|---|---|
Timestamp | datetime.datetime value | Time stamp of the beginning of test suite execution, for example, |
ExecutionTime | Floating-point value | Time taken for test suite execution in seconds (up to millisecond precision). |
Number of tests in the test suite. This number includes passed, failed, and incomplete tests.
Number of passing tests in the test suite.
Number of failing tests in the test suite.
Number of incomplete tests in the test suite.
Result details for test cases, returned as a list of polyspace.test.TestCaseResult objects with one object per test case. This property is the primary way to drill down into details of test suite results.
For more information on the object, see polyspace.test.TestCaseResult.
Results of assessments in suite configuration (if any), specified as a polyspace.test.SuiteConfigResult object. This object covers results of assessments in the PST_SUITE_CONFIG macro.
For more information on suite configuration, see Group C/C++ Tests into Suites with Common Setup and Teardown Code.
Results of assessments in the suite setup function (if any), specified as a polyspace.test.SuiteSetupResult object. This object covers results of assessments in the function registered in the PST_SUITE_SETUP macro.
For more information on suite setup, see Group C/C++ Tests into Suites with Common Setup and Teardown Code.
Results of assessments in the suite teardown function (if any), specified as a polyspace.test.SuiteTeardownResult object. This object covers results of assessments in the function registered in the PST_TEST_TEARDOWN macro.
For more information on suite teardown, see Group C/C++ Tests into Suites with Common Setup and Teardown Code.
Examples
This example shows to print the names of failing test suites after running tests in a project.
In general, you generate and manage Polyspace
Test™ results by using classes from the polyspace.project and polyspace.test modules. Before starting, make sure you can import these modules on a Python shell or in a Python script without errors. For more information, see Set Up Python API for Polyspace.
Import the required modules:
import polyspace.project import polyspace.test import osAdd source files and xUnit test files to a project. This example uses some example source and test files available with a Polyspace Test installation. Instead, you can use your own sources and tests.
examples_path = os.path.join(polyspace.__install_path__, "polyspace", "examples", "pstest", "Getting_Started_Example") polyspaceProject = polyspace.project.Project("newProject") polyspaceProject.Code.Files.add(os.path.join(examples_path, "sources", "utils.c")) polyspaceProject.IncludePaths.add(os.path.join(examples_path, "includes")) polyspaceProject.Tests.Files.add(os.path.join(examples_path, "tests", "test.c"))Run the tests added to the project.
res = polyspace.test.run(polyspaceProject)Print the names of test suites that contain at least one failing test.
for suiteIndex in range(len(res.TestSuiteResults)): # Read result of test suite resTestSuite = res.TestSuiteResults[suiteIndex] if resTestSuite.Status.Failed: print(resTestSuite.Name)Alternatively, you can simply iterate through the list of test suites as follows:
for suiteIndex in res.TestSuiteResults: if resTestSuite.Status.Failed: print(resTestSuite.Name)If you use the example source and test files, you should see the suite name
updateStateTestsprinted. This suite has one failing test.
Version History
Introduced in R2024b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)