MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

classdef testConfigurePlotAppExample < matlab.uitest.TestCase


methods (Test)
function test_SampleSize(testCase)
app = ConfigurePlotAppExample;
testCase.addTeardown(@delete,app);


testCase.type(app.SampleSizeEditField,12);
testCase.press(app.UpdatePlotButton);


ax = app.UIAxes;
surfaceObj = ax.Children;
testCase.verifySize(surfaceObj.ZData,[12 12]);
end


function test_Colormap(testCase)
app = ConfigurePlotAppExample;
testCase.addTeardown(@delete,app);


testCase.choose(app.ColormapDropDown,'Winter');
testCase.press(app.UpdatePlotButton);


expectedMap = winter;
ax = app.UIAxes;
testCase.verifyEqual(ax.Colormap,expectedMap);
end
end


end


At the command prompt, run the tests.


results = runtests('testConfigurePlotAppExample')


Running testConfigurePlotAppExample
..
Done testConfigurePlotAppExample




results =


1×2 TestResult array with properties:


Name


Overview of App Testing Framework
Free download pdf