Main Content

pstest.exportToPolyspaceProfilingResults

(MATLAB Function) Export coverage results from Simulink Coverage, Simulink Test, or MATLAB Test to Polyspace Test

Since R2025a

Description

[resultFilePath,justificationsFilePath] = pstest.exportToPolyspaceProfilingResults(elementToExport) exports a Polyspace® profiling results (.psprof) file that contains the coverage results in elementToExport. By using this function, you can combine the coverage results of your Simulink® model or MATLAB® code with the coverage results of your C/C++ code in a single results file.

example

[resultFilePath,justificationsFilePath] = pstest.exportToPolyspaceProfilingResults(elementToExport,folder,mainFile,writeMode) exports the coverage results in elementToExport in the folder specified in folder, using the name specified in mainFile, and following the file overwriting method specified in writeMode.

Examples

collapse all

Collect coverage metrics for MATLAB® unit tests and export the coverage results as a Polyspace® profiling results (.psprof) file.

The source file QuadraticPolynomial.m defines the class QuadraticPolynomial and its methods. The constructor of this class accepts three objects of numeric data type and defines a quadratic polynomial with these three values as coefficients. The class also defines a method solve that returns the two solutions when the quadratic polynomial is set to zero. The unit test QuadraticPolynomialTest1 defines two test methods that test the solve method against real and complex solutions.

Collect Coverage Information

To collect coverage information, create a test runner that provides programmatic access to the statement and function coverage information for source code in the file QuadraticPolynomial.m.

import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.codecoverage.CoverageResult

runner = testrunner("textoutput");
format = CoverageResult;
plugin = CodeCoveragePlugin.forFile("QuadraticPolynomial.m",Producing=format);
addPlugin(runner,plugin)

Create a test suite from the QuadraticPolynomialTest1 class and run the tests.

suite1 = testsuite("QuadraticPolynomialTest1");
run(runner,suite1);
Running QuadraticPolynomialTest1
..
Done QuadraticPolynomialTest1
__________

Collect the coverage results from the Result property of the CoverageResult object.

coverageforExport = format.Result;

Export Coverage Results

Convert the coverage results to Polyspace results format (.psprof).

pstest.exportToPolyspaceProfilingResults(coverageforExport);

The coverage information is exported to the file output.psprof. You can open this file and review the coverage results by using the Polyspace Platform user interface.

Input Arguments

collapse all

Coverage results for a Simulink model or MATLAB code, specified as a cvdata object, a cvdatagroup object, or a matlab.coverage.Result object.

Full path to a writable folder where the exported Polyspace profiling results file (.psprof) is stored, specified as a character vector or a string scalar.

Example: pwd

Name of the exported Polyspace profiling results file, including the extension psprof, specified as a character vector or a string scalar..

Example: "output.psprof"

File overwriting method:

  • "unique" — Export the result file with a unique name without overwriting any file in folder.

  • "overwrite" — Overwrite existing files with the name mainFile.

Output Arguments

collapse all

The full path to the exported Polyspace profiling results file (.psprof).

Data Types: char

The full path to the justification file, (.psprof.filter) , returned as a character vector. This file contains the justifications for missing or low coverage that is present in elementToExport.

Data Types: char

Version History

Introduced in R2025a