The Jenkins plugin for MATLAB® enables you to easily run your MATLAB tests and generate test artifacts in formats such as JUnit, TAP, and Cobertura code coverage reports.
To invoke this plugin, select "Run MATLAB Tests" from the Add build step list.
Use the plugin as part of the Jenkins build step to run MATLAB tests in two distinct modes:
- Automatic
- Custom
Enter the value returned by “matlabroot” in the field named “MATLAB root”.
This option finds tests written using the MATLAB unit testing framework and/or Simulink Test and runs them. If the code is organized using projects, it will locate all test files in the project that have been classified as "Test". If the code does not leverage projects or uses a MATLAB version prior to R2019a, the plugin will discover all tests in the current Jenkins workspace including subfolders.
If you are using a source code management (SCM) system such as Git, then the job must include an appropriate SCM configuration to check out the code before running the MATLAB plugin. If you do not use any SCM systems to manage your code, then an additional build step is required to ensure the code is available in the workspace before running the MATLAB plugin.
The automatic test running feature enables you to generate different types of test artifacts. They could be used with other Jenkins plugins as part of a post-build action to publish the test results. To configure the Jenkins build for running MATLAB tests automatically, follow these steps.
- Select the Test mode as Automatic to run tests (Automatic is the default mode).
- Select the desired test artifacts. You can also choose not to generate any test artifacts.
The selected test artifact(s) will be stored in the “matlabTestArtifacts” folder of the Jenkins workspace.
If the user does not select any test artifact generation checkboxes, this folder will not be created under the workspace and no test artifacts will be generated. However, test execution still occurs and test failures will fail the build.
The Automatic test run mode generates a MATLAB script file named “runMatlabTests.m” in the Jenkins workspace. The plugin uses this file to run tests and generate test artifacts. You may review the MATLAB script to understand the test workflow.
This option enables you to develop your custom MATLAB commands for running tests.
- From the "Test mode" dropdown list, select “Custom” option.
- In "MATLAB command” text box, enter your MATLAB command. Separate multiple commands by commas or semicolons.
Note: If you require several MATLAB commands to execute your test session, consider writing a MATLAB script or function as part of your repository and executing the script or function instead. Test artifacts are not autogenerated if you choose to run tests using your custom MATLAB commands. You can generate these and other artifacts by configuring a test runner in the script or function invoked by the command. The build will fail if the execution of any MATLAB command causes an error.
If you have any questions or suggestions, please feel free to contact MathWorks.
MIT © 2019 The MathWorks, Inc.
Overall | Linux | Windows | Mac |
---|---|---|---|