Hi Erik,
The problem here is indeed the fact that the testCase is getting overwritten. Hence why if you assign the output of the load command to a structure the issue is not encountered. These steps are similar to something like the following:
classdef SomethingNotATestCase
methods
function verifyEqual(obj,varargin)
end
end
end
Then inside the test, doing something like this:
classdef minExample < matlab.unittest.TestCase
methods(Test)
function test1(testCase)
testCase = SomethingNotATestCase
verifyEqual(testCase,1,2);
end
end
end
In both of these cases you have overwritten the testCase with something that is not the right thing to produce a test failure. This is perfectly allowable by the language. This is part of the reason why it is suggested to use the functional form of the load command, including with the output argument, because when you dont use the output argument you "poof" variables into the workspace, and this can overwrite existing variables. If you assign it to an output argument then you explicitly name your variable, and are much less likely to overwrite another variable unknowingly.
Hope that helps!
Andy