Quantcast

Documentation Center

  • Trial Software
  • Product Updates

run

Class: matlab.unittest.TestCase
Package: matlab.unittest

Run TestCase test

Syntax

result = run(testCase)
result = run(testCase,testMethod)

Description

result = run(testCase) uses testCase as a prototype to run a TestSuite array created from all test methods in the class defining testCase. This suite is run using a TestRunner object configured for text output.

result = run(testCase,testMethod) uses testCase as a prototype to run a TestSuite array created from testMethod. This test is run using a TestRunner object configured for text output.

This is a convenience method to allow interactive experimentation of TestCase classes in MATLAB®, yet running the tests contained in them using a supported TestRunner object.

Input Arguments

testCase

matlab.unittest.TestCase instance

testMethod

Name of desired test method, specified as one of the following:

  • string

  • meta.method instance

The method must correspond to a valid Test method of the testCase instance.

Output Arguments

result

A matlab.unittest.TestResult object containing the result of the test run.

Examples

expand all

Run Test Directly from Test Case

Add the FigurePropertiesTest.m test case file to a folder on your MATLAB path.

classdef FigurePropertiesTest < matlab.unittest.TestCase
 
    properties
        TestFigure
    end
 
    methods(TestMethodSetup)
        function createFigure(testCase)
            %comment
            testCase.TestFigure = figure;
        end
    end
 
    methods(TestMethodTeardown)
        function closeFigure(testCase)
            close(testCase.TestFigure);
        end
    end
 
    methods(Test)
 
        function defaultCurrentPoint(testCase)
 
            cp = get(testCase.TestFigure, 'CurrentPoint');
            testCase.verifyEqual(cp, [0 0], ...
                'Default current point is incorrect')
        end
 
        function defaultCurrentObject(testCase)
            import matlab.unittest.constraints.IsEmpty;
 
            co = get(testCase.TestFigure, 'CurrentObject');
            testCase.verifyThat(co, IsEmpty, ...
                'Default current object should be empty');
        end
 
    end
 
end

Create a testcase object.

tc = FigurePropertiesTest;

Run the tests.

tc.run;
Running FigurePropertiesTest
..
Done FigurePropertiesTest
__________

All tests passed.

See Also

|

Was this topic helpful?