Main Content

addAssessment

Class: sltest.testmanager.TestCase
Namespace: sltest.testmanager

Add assessments to a test case

Since R2022a

Syntax

addedAssessments = addAssessment(tc,assessmentsObj)
addedAssessments = addAssessment(tc,assessmentsObj,'AddSymbols' = true)
addedAssessments = addAssessment(tc,assessmentsObj,'AddSymbols' = false)

Description

addedAssessments = addAssessment(tc,assessmentsObj) adds an array of assessment objects, including the symbols uses in the assessments, to the specified test case.

addedAssessments = addAssessment(tc,assessmentsObj,'AddSymbols' = true) behaves the same as the previous syntax.

addedAssessments = addAssessment(tc,assessmentsObj,'AddSymbols' = false) adds assessment objects to the test case, but does not add the associated symbols. The symbols in the assessment have a Scope value of Unresolved. You must associate the symbols with an item in the assessment before you run the test case.

Input Arguments

expand all

Test case for which to get assessments, specified as an sltest.testmanager.TestCase object.

Assessments to add to the test case, specified as an array of sltest.testmanager.Assessment objects.

Output Arguments

expand all

Assessments added to the test case, returned as an array of sltest.testmanager.Assessment objects.

Examples

expand all

Load an existing test file that contains assessments. Get the assessments and then create a new test case and add the assessments to the new test case.

tf = sltest.testmanager.load('test_traffic.mldatx');
ts = getTestSuites(tf);
tc = getTestCases(ts); 

assessObjs = getAssessments(tc);
tc_New = createTestCase(ts);
tc_NewAssess = addAssessment(tc_New,assessObjs);

Clear and close the Test Manager.

sltest.testmanager.clear
sltest.testmanager.clearResults
sltest.testmanager.close

Load an existing test file that contains a test suite and a test case with assessments.

tf = sltest.testmanager.load('test_traffic.mldatx');
ts = getTestSuites(tf);
tc = getTestCases(ts); 
assessObjs = getAssessments(tc);

Create a new test suite with three test cases.

tsNew = tf.createTestSuite;
tsNew.createTestCase;
tsNew.createTestCase;
tsNew.createTestCase;

Use arrayfun to copy the assessments from the original test case to all of the new test cases in the new test suite.

arrayfun(@(x)addAssessment(x,assessObjs),...
    tsNew.getTestCases,'UniformOutput',false);

Clear and close the Test Manager.

sltest.testmanager.clear
sltest.testmanager.clearResults
sltest.testmanager.close

Version History

Introduced in R2022a