Run Tests and Assess Quality in Referenced Projects
Separating a large project into referenced projects is called componentization. This example shows how to componentize a project that contains MATLAB® algorithms and requirements, and then run the tests and assess the quality metrics on those referenced projects.
Open the MyMath project.
openProject("MyMath");The project contains:
A MATLAB function, located in the
sourcefolderA Microsoft® Word document that defines a test specification, located in the
documentsfolderRequirement sets that contain test requirements imported from Microsoft Word and functional requirements, located in the
documentsfolderMATLAB tests for the function, located in the
testsfolderLinks from the test requirements to the tests, located in the
testsfolderAdditional MATLAB functions, Microsoft Word documents, requirement sets, tests, and links in the
MyAddandMySubtractsubfolders

The myMath function takes two numeric inputs and an operation input that specifies which math operation to use. The function uses the myAdd and mySubtract functions for addition and subtraction. Examine the myMath function.
type myMathfunction y = myMath(u,v,operation)
% myMath - Adds or subtracts inputs u and v depending on the operation
% specified
switch operation
case "add"
y = myAdd(u,v);
case "subtract"
y = mySubtract(u,v);
otherwise
error("Specify the operation as either add or subtract.")
y = [];
end
end
Componentize the Project
The MyAdd and MySubtract folders contain the myAdd and mySubtract functions, as well as the requirements, Microsoft Word test specifications, tests, and links for those functions.

Componentize the project by extracting the MyAdd and MySubtract folders into referenced projects. Right-click the MyAdd folder and select Extract to Reference Project.
In the Create Reference Project dialog box, set Name to MyAdd, then click OK. MATLAB opens the References tab, which displays the referenced projects for the MyMath project.

Extract the MySubtract folder to a referenced project by right-clicking the folder and selecting Extract to Reference Project.. Name the new project MySubtract.
Componentizing the MyAdd and MySubtract folders removes them from the project and creates new projects in the parent folder of the current project. However, the folders remain in the MyMath project. Remove the MyAdd and MySubtract folders. In the Project panel, right-click the MyAdd folder and select Delete. Repeat this process for the MySubtract folder.
Create Project-Based Test Suites
Open the MATLAB Test Manager.
matlabTestManager
The MATLAB Test Manager includes the tests from the referenced projects. Organize the tests by creating test suites for each individual project, starting with the MyAdd project.
In the drop-down list on the left, select Manage Custom Test Suites.
In the Test Suite Manager, click New.
Set Name to
MyAddTests.Specify the relative path of the
testsfolder in theMyAddproject by setting Base Folders to../MyAdd/tests.Click Save.

Create additional test suites for the tests from the MySubtract and MyMath projects. To create the test suite that contains the tests in the MySubtract project, set Base Folders to ../MySubtract/tests. To create the test suite that contains the tests in the MyMath project, set Base Folders to tests.
Verify the Algorithms
Verify the algorithms by running the tests with coverage enabled. Click the Code Coverage button
, then select Enable Code Coverage and set the metric level to MC/DC. In the drop-down list to the left of the Run button
, select the MyMathTests test suite, then run the tests by clicking the Run button
.

The tests pass, but the statement coverage is not 100%.
Assess Quality Metrics
Assess the quality metrics for the project by opening the Code Quality Dashboard.
codeQualityDashboard

The Code Quality Dashboard indicates that there is one warning in the source code, 42.9% of the tests pass, and 57.1% of the tests were not run. Similarly, the passed tests verified 33.3% of the requirements, and 66.7% of the requirements link to tests that have not run. There is no code coverage data because not all of the tests in the project ran.
Verify the remaining algorithms by clicking the Run button
, which runs all tests in the project.

The Code Quality Dashboard indicates that there is one warning in the source code, 100% function and decision coverage, 93.3% statement coverage, and all requirements are verified.