% Extract blood pressure data from app
t = cell2table(testCase.App.Tab2.Children.Data);
t.Var2 = categorical(t.Var2);
allMales = t(t.Var2=='Male',:);
maleDiastolicData = allMales.Var7';
maleSystolicData = allMales.Var8';
% Verify ylabel and that male Systolic data shows
ax = testCase.App.UIAxes;
testCase.verifyEqual(ax.YLabel.String,'Systolic')
testCase.verifyEqual(ax.Children.YData,maleSystolicData)
% Switch to 'Diastolic' reading
testCase.choose(testCase.App.BloodPressureSwitch,'Diastolic')
% Verify ylabel changed and male Diastolic data shows
testCase.verifyEqual(ax.YLabel.String,'Diastolic')
testCase.verifyEqual(ax.Children.YData,maleDiastolicData);
end
function test_plottingOptions(testCase)
% Press the histogram radio button
testCase.press(testCase.App.HistogramButton)
% Verify xlabel updated from 'Weight' to 'Systolic'
testCase.verifyEqual(testCase.App.UIAxes.XLabel.String,'Systolic')
% Change the Bin Width to 9
testCase.choose(testCase.App.BinWidthSlider,9)
% Verify the number of bins is now 4
testCase.verifyEqual(testCase.App.UIAxes.Children.NumBins,4)
end
function test_tab(testCase)
% Choose Data Tab
dataTab = testCase.App.Tab2;
testCase.choose(dataTab)
% Verify Data Tab is selected
testCase.verifyEqual(testCase.App.TabGroup.SelectedTab.Title,'Data')
end
end
end
Run the tests.
results = runtests('TestPatientsDisplay');
Running TestPatientsDisplay
================================================================================
Verification failed in TestPatientsDisplay/test_gender.
---------------------
Framework Diagnostic:
---------------------
verifyNumElements failed.
--> The value did not have the correct number of elements.
33 Unit Testing