Main Content

sltest.testmanager.moveTests

Move test cases or test suites to a new location

Description

objArray = sltest.testmanager.moveTests(srcObjArray,targetObj) moves test cases or test suites to another test file or test suite.

example

sltest.testmanager.moveTests(tcToMove,targetTC) moves the specified test case above or below the target test case location within the same test suite. The target location depends on whether the test case to move is above or below that target test case. See targetTC for details.

example

Examples

collapse all

% Create test structure
tf1 = sltest.testmanager.TestFile('Test File 1');
ts = tf1.createTestSuite('Test Suite');

% Create new test file
tf2 = sltest.testmanager.TestFile('Test File 2');

% Move test suite to Test File 2
objArray = sltest.testmanager.moveTests(ts,tf2)
objArray = 

  TestSuite with properties:

           Name: 'Test Suite'
    Description: ''
        Enabled: 1
       TestFile: [1x1 sltest.testmanager.TestFile]
       TestPath: 'Test File 2 > Test Suite'
         Parent: [1x1 sltest.testmanager.TestFile]

Create a test file, test suite, and three test cases in the test suite. Move the third test case to before the second test case.

tf = sltest.testmanager.TestFile('Test File');
ts = createTestSuite(tf,'New Test Suite');
tc1 = createTestCase(ts,"baseline","TestCase 1");
tc2 = createTestCase(ts,"baseline","TestCase 2");
tc3 = createTestCase(ts,"baseline","TestCase 3");

tc = getTestCases(ts);
disp({tc.Name})

sltest.testmanager.moveTests(tc2,tc3);
tc_moved = getTestCases(ts);
disp({tc_moved.Name})
    {'TestCase 1'}    {'TestCase 2'}    {'TestCase 3'}

    {'TestCase 1'}    {'TestCase 3'}    {'TestCase 2'}

Input Arguments

collapse all

Test cases or test suites to move, specified as an array of sltest.testmanager.TestCase or sltest.testmanager.TestSuite objects.

The destination test file or test suite to move to, specified as an sltest.testmanager.TestFile or sltest.testmanager.TestSuite object.

Test case to move, specified as a sltest.testmanager.TestCase object.

Target test case above or below which to move the test case, tcToMove, specified as a sltest.testmanager.TestCase object. If the tcToMove is below the targetTC, it is moved above the targetTC. If the tcToMove is above the targetTC, it moved below the targetTC.

Output Arguments

collapse all

Test cases or test suites at the target destination location, returned as an array of sltest.testmanager.TestCase or sltest.testmanager.TestSuite objects.

Version History

Introduced in R2015b