Qualify Changes by Comparing Previous Runs Using the MATLAB Test Manager - MATLAB & Simulink (original) (raw)

Main Content

You can qualify changes to source or test code in MATLABĀ® by using the MATLAB Test Manager to capture the current state of test and coverage as a reference. When you make changes to your project, you can then re-run the tests and compare the current results to the reference results. Qualifying changes helps you prevent introducing regressions into your code base.

Capture Reference Results

To capture the current state of test and coverage results as a reference:

  1. Select the test suite that has the tests you want to run by clicking the drop-down menu to the left of the Run button and selectingAll Tests in Current Project or a custom test suite. For more information about test suites, see Create, Manage, and Run Test Suites.
  2. Enable coverage and select the desired code coverage metrics to collect. For more information, see Collect Code Coverage.
  3. Customize the test run with your desired settings for strict checks, output detail, and logging level. For more information, see Customize Test Run.
  4. Run the tests by clicking the Run button .

The MATLAB Test Manager stores the five most recent test runs. To save the current test results to an external file, export the test results to a JSON file. For more information, see Import and Export Test Runs From MATLAB Test Manager.

Update Code and Run Tests

After you make changes to the source or test code in the MATLAB files in the project, you can run the tests and compare the updated results to the reference results.

To avoid overwriting the reference results in the MATLAB Test Manager, first run the tests by using the Test Browser. Iteratively run and change the tests until you are ready to compare the current test results to the reference results. Only then run the test suite in the MATLAB Test Manager. To establish consistency in the test and coverage results to enable comparing runs, run the tests in the same test suite with the same coverage metrics and customizations.

Compare Results to Previous Runs

To determine if the changes introduced new test failures or decreased the coverage percentages, manually compare the current results to the reference results in theMATLAB Test Manager.

To view a previous run in the MATLAB Test Manager, click the drop-down menu to the left of the Run button and, under Previous Runs, select the run.

The mouse points to a previous run of All Tests in Current Project.

The MATLAB Test Manager opens the previous run and displays the test suite, the results, and lists the date and time that the suite ran.

The MATLAB Test Manager shows the test results from a previous run.

If you ran the tests with coverage enabled, you can view a summary of the coverage results for the previous run by pointing to the Statement button. Open the report by clicking the Statement button. Alternatively, click the Report button and select the report under Code Coverage Reports.

If you ran equivalence tests that generated C/C++ code as a static library and executed in SIL or PIL mode, you can open the generated code coverage report by clicking the Report button and selecting the report under Generated Code Coverage Reports.

To generate a report from the test results in a previous run, click the Report button . Then, under Test Result Reports, click Generate Test Result Report.

To navigate to the current test run, click the drop-down list on the left of the menu and select All Tests in Current Project or a custom test suite.

See Also

Apps

Topics