MATLAB Programming Fundamentals - MathWorks
ans = 3×1 cell array 'ExampleTagTest/testD' 'ExampleTagTest/testB' 'ExampleTagTest/testC' Select all the tests with the 'Feature ...
Write Tests Using Shared Fixtures This example shows how to use shared fixtures when creating tests. You can share test fixtures ...
'(x^2 + 1) + (5x + 2) = x^2 + 5x + 3']; testCase.verifyEqual(actual, expected, msg) end function testMultiplication(testCase) p1 ...
function testDesposit(testCase) b = BankAccount(1234, 100); b.deposit(25) testCase.verifyEqual(b.AccountBalance, 125) end functi ...
result = run(suiteFolder); Setting up PathFixture. Description: Adds 'C:\Program Files\MATLAB\R2013b\help\techdoc\matlab_oop\exa ...
Create Basic Custom Fixture This example shows how to create a basic custom fixture that changes the display format to hexadecim ...
function test1(testCase) testCase.applyFixture(FormatHexFixture); actStr = getColumnForDisplay([1;2;3], 'Small Integers'); expSt ...
Related Examples “Create Advanced Custom Fixture” on page 33-75 “Write Tests Using Shared Fixtures” on page 33-68 33 Unit Test ...
Create Advanced Custom Fixture This example shows how to create a custom fixture that sets an environment variable. Prior to tes ...
'An existing UserName environment variable must be defined.') fixture.addTeardown(@setenv, 'UserName', originalUserName) fixture ...
function setup(fixture) originalUserName = getenv('UserName'); fixture.assertNotEmpty(originalUserName, ... 'An existing UserNam ...
Apply Custom Fixture as Shared Fixture In your working folder, create three test classes using a shared fixture. Using a shared ...
Setting up UserNameEnvironmentVariableFixture Done setting up UserNameEnvironmentVariableFixture: Set the UserName environment v ...
Alternate UserNameEnvironmentVariableFixture Class Definition classdef UserNameEnvironmentVariableFixture < ... matlab.unitte ...
Related Examples “Create Basic Custom Fixture” on page 33-72 “Write Tests Using Shared Fixtures” on page 33-68 See Also ...
Create Basic Parameterized Test This example shows how to create a basic parameterized test. Create Function to Test In your wor ...
Define properties Block Define the properties used for parameterized testing. In the TestCarpet class, define these properties i ...
This method uses the level property and, therefore, results in three test elements—one for each value in level. The testClass me ...
end methods (Test) function testRemainPixels(testCase, level) % expected number pixels equal to 1 expPixelCount = 8^level; % act ...
'TestCarpet/testRemainPixels(level=large)' 'TestCarpet/testClass(type=single,level=small)' 'TestCarpet/testClass(type=single,lev ...
«
62
63
64
65
66
67
68
69
70
71
»
Free download pdf