Skip to content

Files

Latest commit

75868aa · Sep 27, 2023

History

History
65 lines (39 loc) · 5.14 KB

Run-MATLAB-Tests.md

File metadata and controls

65 lines (39 loc) · 5.14 KB

Run MATLAB Tests on Bamboo CI Server

This example shows how to run a suite of MATLAB® unit tests with Bamboo®. The example demonstrates how to:

  • Create a build plan to access MATLAB tests hosted in a remote repository.
  • Define a task in the plan to run the tests and generate test and coverage artifacts.
  • Build the plan and examine the test results and the generated artifacts.

The build 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 a statement in the Command Window. The statement to run depends on your MATLAB release:

R2023a and Earlier Starting in R2023b
matlab.project.example.timesTable openExample("matlab/TimesTableProjectExample")

For more information about the Times Table App project, see Explore an Example Project.

Prerequisites

To follow the steps in this example:

  • MATLAB and the plugin for MATLAB must be installed on your Bamboo Continuous Integration (CI) server. For information on how to install a plugin in Bamboo, see Installing a plugin.
  • The Times Table App project must be under 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.

Create Plan to Run MATLAB Tests

Create a new build plan and configure it by following these steps:

  1. In your build dashboard, from the top menu bar, select Create > Create plan. Then, on the Configure plan page, specify your build plan details.

configure_plan_details

  1. On the Configure plan page, in the Link repository to new build plan section, specify the repository for your build plan.

configure_plan_repository

  1. To confirm your plan details, click Configure plan. A new page opens that lets you add tasks to the default job of your plan. By default, Bamboo includes the Source Code Checkout task, which is responsible for checking out code from your repository.

  2. To run MATLAB tests as part of your build, add the Run MATLAB Tests task by clicking Add task and then selecting Run MATLAB Tests from the Task types interface. You can access the task by typing MATLAB in the text box located at the upper-right corner of the interface.

add_task

  1. In the Run MATLAB Tests task configuration interface, from the Executable list, select the MATLAB release to use for the task. Then, specify the artifacts to generate in the working directory. In this example, the plugin uses MATLAB R2023b to run the tests and generate JUnit-style test results, a PDF test report, and an HTML code coverage report. For more information about the tasks provided by the plugin, see Plugin Configuration Guide.

run_matlab_tests

  1. To publish the JUnit-style test results, add the JUnit Parser task to your job. To make sure that the task runs regardless of the build status, specify it as a final task.

  2. Create artifact definitions for the artifacts you want to access from the build dashboard. To create artifact definitions, select the Artifacts tab. Then, for each artifact, click Create artifact and specify the required values.

artifact_definitions

Run Tests and Inspect Artifacts

Now that your plan configuration is complete, you can run your plan.

  1. Click the link to your plan at the upper-left corner of the page.
  2. At the upper-right corner of the plan page, enable the plan by selecting Actions > Enable plan.
  3. Select Run > Run plan.

Bamboo triggers a build, runs it, and displays a green or red bar to indicate its success or failure. In this example, the build succeeds because all of the tests in the Times Table App project pass.

To access the test and coverage artifacts, select the Tests and Artifacts tabs. For example, select the Artifacts tab to access the generated HTML code coverage and PDF test reports.

build_outcome

See Also