I would like to modify a property (not a TestParameter) after the test suite is created but I am getting an error "No public field myparam exists for class matlab.unittest.Test". Here is what I am doing in terms of code: I create a class unitclass.m
classdef unitclass < matlab.unittest.TestCase properties ( SetAccess = public ) myparam = 2; end properties (TestParameter) test_param1 = struct('Low', 0.1,'Medium', 0.5); test_param2 = struct('Cold', 10,'Hot', 200); end methods (Test) function testError(testcase,test_param1,test_param2) output = test_param1 * test_param2; testcase.myparam testcase.verifyLessThan(output,20); end endend
Then a create a custom unittest SDLTest.m class to modify my parameter
classdef SDLTest < matlab.unittest.Test methods (Static = true) function this = set_myparam(this,myparam) for i = 1:length(this) this(i).myparam = myparam; end end endend
when I try to execute the code
mySuite = matlab.unittest.TestSuite.fromClass(?unitclass)results = SDLTest.set_myparam(mySuite,1)
I get the error "No public field myparam exists for class matlab.unittest.Test".
Help with this is greatly appreciatd.
Thanks.
Best Answer