MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
import matlab.unittest.TestSuite
import matlab.unittest.TestRunner

suite = TestSuite.fromClass(?ExampleTest);

Create a test runner with no plugins. This code creates a silent runner and provides you
with complete control over the installed plugins.

runner = TestRunner.withNoPlugins;

Run the tests.

result = runner.run(suite);

Add AssertionCountingPlugin to the runner and run the tests.

runner.addPlugin(AssertionCountingPlugin)
result = runner.run(suite);

## Running a total of 3 tests
### Running test: ExampleTest/testOne
### Running test: ExampleTest/testTwo
### Running test: ExampleTest/testThree
## Done running tests
______________________________
Total Assertions: 2
1 Passed, 1 Failed

See Also
addlistener | matlab.unittest.TestCase | matlab.unittest.TestRunner |
matlab.unittest.fixtures.Fixture |
matlab.unittest.plugins.OutputStream |
matlab.unittest.plugins.TestRunnerPlugin

Related Examples



  • “Write Plugins to Extend TestRunner” on page 33-113

  • “Write Plugin to Save Diagnostic Details” on page 33-123


33 Unit Testing

Free download pdf