MATLAB Programming Fundamentals - MathWorks
Author Class-Based Unit Tests in MATLAB To test a MATLAB program, write a unit test using qualifications that are methods for te ...
end end Qualifications are methods for testing values and responding to failures. This table lists the types of qualifications. ...
plus function, the actual value might be plus(2,3) and the expected value 5. Within the test function, you pass the actual and e ...
“Create Simple Test Suites” on page 33-102 “Run Tests for Various Workflows” on page 33-105 “Analyze Test Case Results” on page ...
Write Simple Test Case Using Classes This example shows how to write a unit test for a MATLAB® function, quadraticSolver.m. Crea ...
end The following steps show how to create specific tests. Put these tests inside the methods block with the (Test) attribute. C ...
expSolution = [-1+3i, -1-3i]; testCase.verifyEqual(actSolution,expSolution) end The order of the tests within the block does not ...
res = 1x2 TestResult array with properties: Name Passed Failed Incomplete Duration Details Totals: 2 Passed, 0 Failed, 0 Incompl ...
0.042604 seconds testing time. See Also Related Examples “Author Class-Based Unit Tests in MATLAB” on page 33-47 “Write Setup a ...
Write Setup and Teardown Code Using Classes In this section... “Test Fixtures” on page 33-56 “Test Case with Method-Level Setup ...
TestFigure end methods(TestMethodSetup) function createFigure(testCase) % comment testCase.TestFigure = figure; end end methods( ...
example file. Typically, you set up the path using a PathFixture. this example performs the setup and teardown activities manual ...
function testCallback(~,~) callbackExecuted = true; end b = BankAccount(1234, 100); b.addlistener('InsufficientFunds', @testCall ...
Types of Qualifications Qualifications are functions for testing values and responding to failures. There are four types of qual ...
Type of Test Verification Assumption Assertion Fatal Assertion Value meets given constraint. verifyThat assumeThat assertThat fa ...
Type of Test Verification Assumption Assertion Fatal Assertion Function throws specified exception. verifyError assumeError asse ...
Tag Unit Tests You can use test tags to group tests into categories and then run tests with specified tags. Typical test tags id ...
Several of the tests in class ExampleTagTest are tagged. For example, testD is tagged with 'Unit' and 'FeatureA'. One test, test ...
results = runtests({'ExampleTagTest','ExampleTagClassTest'},'Tag','FeatureA'); Running ExampleTagTest .. Done ExampleTagTest Ru ...
suite = [sA sB]; {suite.Name}' ans = 3×1 cell array 'ExampleTagTest/testE' 'ExampleTagTest/testD' 'ExampleTagClassTest/testG' Se ...
«
61
62
63
64
65
66
67
68
69
70
»
Free download pdf