- I have a matlab unit test class. Here i am using setup method to form structure i.e. 'testCase.out' this structure have n values here n=4.
- Test method is used to verify equality of values.
classdef ClassTest < matlab.unittest.TestCase properties (Access = private) out end methods (TestClassSetup) function FirstSetup(testCase) n=4; for i=1:n testCase.out(i).name= ['Test_', num2str(i)]; testCase.out(i).value = i; end end end methods (Test) function MyTest(testCase) for k=1:length(testCase.out) Test = testCase.out(k).name; testCase.verifyEqual(testCase.out(k).value,2); end end end end
Now to run this test:
import matlab.unittest.TestSuitesuite = TestSuite.fromClass(?ClassTest);result = run(suite);
The result is failed as k=1,3 and 4 is not equal values. Only k=2 value is equal.
Question:
How could we create a test such that for value 2 the test will pass and for other test will fail. So i want result table i.e. Test1 = fail, Test2=Pass, Test3=fail and Test4 = fail.
how could we use above same test and get result table for n numbers with pass fail status?
Best Answer