You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 27, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: examples/Run-MATLAB-Tests.md
+19-23Lines changed: 19 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@ This example shows how to run a suite of MATLAB® unit tests with Jenkins&tra
4
4
5
5
* Configure Jenkins to run a freestyle project including MATLAB tests.
6
6
* Interface Jenkins with a remote repository that contains the tests.
7
-
* Build the freestyle project and examine the generated test artifacts.
7
+
* Build the freestyle project and examine the generated artifacts.
8
8
9
-
The freestyle project runs the tests in the Times Table App MATLAB project (which requires R2019a or later). You can create a working copy of the project files and open the project in MATLAB by running this statement in the Command Window:
9
+
The freestyle project runs the tests in the Times Table App MATLAB project (which requires R2019a or later). You can create a working copy of the project files and open the project in MATLAB by running this statement in the Command Window.
10
10
11
11
```
12
12
matlab.project.example.timesTable
@@ -17,62 +17,58 @@ For more information about the Times Table App example project, see [Explore an
17
17
## Prerequisites
18
18
Running the tests in this example requires you to interface Jenkins with MATLAB as well as a remote repository.
19
19
20
-
* To run MATLAB tests and generate test artifacts, you must install the MATLAB plugin. For information on how to install a plugin in Jenkins, see [Managing Plugins](https://jenkins.io/doc/book/managing/plugins/).
20
+
* To run MATLAB tests and generate artifacts, you must install the plugin for MATLAB. For information on how to install a plugin in Jenkins, see [Managing Plugins](https://jenkins.io/doc/book/managing/plugins/).
21
21
* Jenkins runs the tests in a branch of the remote repository that is specified by a URL. To follow the build steps in this example, the Times Table App project must be under Git™ source control. For example, you can create a new repository for the project using your GitHub® account. For more information, see [Use Source Control with Projects](https://www.mathworks.com/help/matlab/matlab_prog/use-source-control-with-projects.html).
22
-
* To publish the test artifacts using post-build actions, relevant plugins must be installed on Jenkins. For example, the [Cobertura plugin](https://plugins.jenkins.io/cobertura) integrates Cobertura coverage reports to Jenkins, and [JUnit plugin](https://plugins.jenkins.io/junit) publishes JUnit-format test results.
22
+
* To publish the artifacts using post-build actions, relevant plugins must be installed on Jenkins. For example, the [Cobertura plugin](https://plugins.jenkins.io/cobertura) integrates Cobertura coverage reports to Jenkins, and [JUnit plugin](https://plugins.jenkins.io/junit) publishes JUnit-format test results.
23
23
24
24
## Configure Jenkins Project to Run MATLAB Tests
25
25
Create a new project and configure it by following these steps:
26
26
1. In your Jenkins interface, select **New Item** on the left. A new page opens where you can choose the type of your project. Enter a project name, then click **Freestyle project**. To confirm your choices, click **OK**.
2. In the configuration window of your Jenkins project, navigate to the **Source Code Management** section and click **Git**. This option enables Jenkins to interface with a remote repository.
4. In the Jenkins interface, paste the URL into the **Repository URL** box of the **Source Code Management** section. You also can specify the branch to build in the **Branch Specifier** box.
37
+
4. In the project configuration window, paste the URL into the **Repository URL** box of the **Source Code Management** section. You also can specify the branch to build in the **Branch Specifier** box.
5. In the **Build Environment** section of Jenkins, select **Use MATLAB Version**. Then, enter the full path to the MATLAB root folder in the **MATLAB root** box. Jenkins uses MATLAB at the specified location to run the tests.
5. In the **Build Environment** section, select **Use MATLAB version** and specify the MATLAB version you want to use in the build. If your desired MATLAB version is not listed under **Use MATLAB version**, enter the full path to its root folder in the **MATLAB root** box.
48
43
49
-
6. In the **Build** section of Jenkins, select **Add build step > Run MATLAB Tests**. Then, select your desired test artifacts to be generated in the project workspace. The plugin in this example is configured to generate Cobertura code coverage and JUnit test result reports. Furthermore, the coverage report is generated only for the code in the `source` folder located in the root of your repository. For more information on how to configure the plugin, see [Plugin Configuration Guide](../CONFIGDOC.md).
6. In the **Build** section, select **Add build step > Run MATLAB Tests**. Then, select your desired artifacts to be generated in the project workspace. The plugin in this example is configured to generate Cobertura code coverage and JUnit test result reports. Furthermore, the coverage report is generated only for the code in the `source` folder located in the root of your repository. For more information on how to configure the plugin, see [Plugin Configuration Guide](../CONFIGDOC.md).
52
47
53
-
7. In the **Post-build Actions** section of Jenkins, add two post-build actions to publish the Cobertura code coverage and JUnit test result reports. For each report, provide the path to the report file.
7. In the **Post-build Actions** section, add two post-build actions to publish the Cobertura code coverage and JUnit test result reports. For each report, provide the path to the report file.
8. Click **Save** to save the project configuration settings. You can access and modify your settings at a later stage by selecting **Configure** in the project interface.
59
55
60
-
## Run Tests and Inspect Test Artifacts
61
-
To build your Jenkins project and run the tests specified in the repository, click **Build Now** in the project interface, which displays the project name at the top-left of the page. Jenkins triggers a build, assigns it a number under **Build History**, and runs the build. If the build is successful, a blue circle icon appears next to the build number. If the build fails, Jenkins adds a red circle icon. In this example, the build passes because all of the tests specified in the Times Table App project pass.
56
+
## Run Tests and Inspect Artifacts
57
+
To build your freestyle project, click **Build Now** in the project interface, which displays the project name at the top-left of the page. Jenkins triggers a build, assigns it a number under **Build History**, and runs the build. If the build is successful, a blue circle icon appears next to the build number. If the build fails, Jenkins adds a red circle icon. In this example, the build passes because all of the tests in the Times Table App project pass.
Navigate to the project workspace by clicking the **Workspace** icon in the project interface. In this example, the generated test artifacts are in the `matlabTestArtifacts` folder of the workspace.
61
+
Navigate to the project workspace by clicking the **Workspace** icon in the project interface. In this example, the generated artifacts are in the `matlabTestArtifacts` folder of the workspace.
To view the published JUnit test results, open the **Latest Test Result** link in the project interface. In the new page, open the link in the **All Tests** table. The table expands and lists information for each of the test classes within the Times Table App project.
Use this list to add MATLAB versions as axis values to your matrix configuration. The list includes the names of all MATLAB versions that have been registered as a tool in Jenkins.<br>
4
+
In each build iteration, the plugin prepends one of the selected versions to the PATH environment variable and invokes it to perform the build.
5
+
</p>
6
+
<p><br>
7
+
<b>Note:</b> In multi-configuration projects, the values specified by <b>Use MATLAB version</b> take precedence over the values specified by the <b>MATLAB</b> axis.
Specify the location of folders used to select test suite elements, relative to the project root folder. To generate a test suite, the plugin uses only the tests in the specified folders and their subfolders.
4
+
<br>
5
+
Paste the test folder path in the text box. To add more folders, click <b>Add folder.</b>
<p>Specify the location of folders containing source code, relative to the project root folder. The specified folders and their subfolders are added to the top of the MATLAB search path. To generate a coverage report, MATLAB uses only the source code in the specified folders and their subfolders.</p>
3
-
<p>Paste the source folder path in the <b>File path</b> box. To add more folders, click <b>Add folder</b>.</p>
3
+
<p>Paste the source folder path in the <b>Folder path</b> box. To add more folders, click <b>Add folder</b>.</p>
Enter the full path to the MATLAB root folder, which is returned by the <i><b>matlabroot</b></i> function. The specified directory will be prepended to the PATH environment variable, and the specified MATLAB version will be used to perform the build.
3
-
You must not leave this field blank if no MATLAB directory exists on the path. If you leave the field blank, then the system tries to use the MATLAB directory closest to the top of the system path. <br><br><br>Example:<br><br><i><b><u>Windows:</u></b></i><br> C:\Program Files\MATLAB\R2019a <br>
Enter the full path to the MATLAB root folder, which is returned by the <b>matlabroot</b> function. The plugin prepends the folder to the PATH environment variable and uses the specified MATLAB version to perform the build.
3
+
You must not leave this box blank if no MATLAB folder exists on the path. If you leave it blank, the plugin attempts to use the topmost MATLAB folder on the system path.
4
+
<br><br><br>Here are examples of the root folder path on different platforms:<br><br><b>Windows:</b><br> C:\Program Files\MATLAB\R2020b <br>
Copy file name to clipboardExpand all lines: src/main/resources/com/mathworks/ci/UseMatlabVersionBuildWrapper/help.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
<div>
2
2
<p>
3
3
Use this list to specify the MATLAB version for the build. The plugin prepends your specified MATLAB to the PATH environment variable and uses it to perform the build. <br>
4
-
The list includes the names of all MATLAB versions that have been registered as a tool in <u>Jenkins</u>. Select one of the tools, or select <b>Custom…</b> if you want to specify a different version. When you select <b>Custom…</b>, you must enter the full path to the desired MATLAB root folder in the <b>MATLAB root</b> box.
4
+
The list includes the names of all MATLAB versions that have been registered as a tool in Jenkins. Select one of the tools, or select <b>Custom</b> if you want to specify a different version. When you select <b>Custom</b>, you must enter the full path to the desired MATLAB root folder in the <b>MATLAB root</b> box.
5
5
</p>
6
6
<p><br>
7
7
<b>Note:</b> In multi-configuration projects, the value specified by <b>Use MATLAB version</b> takes precedence over the values specified by the <b>MATLAB</b> axis.
0 commit comments