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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)