MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

end
end


end


Import TestSuite Class


At the command prompt, add the matlab.unittest.TestSuite class to the current
import list.


import matlab.unittest.TestSuite


Make sure the SolverTest class definition file is on your MATLAB path.


Create Suite from SolverTest Class


The fromClass method creates a suite from all Test methods in the SolverTest class.


suiteClass = TestSuite.fromClass(?SolverTest);
result = run(suiteClass);


Create Suite from SolverTest Class Definition File


The fromFile method creates a suite using the name of the file to identify the class.


suiteFile = TestSuite.fromFile('SolverTest.m');
result = run(suiteFile);


Create Suite from All Test Case Files in Current Folder


The fromFolder method creates a suite from all test case files in the specified folder. For
example, the following files are in the current folder:



  • BankAccountTest.m

  • DocPolynomTest.m

  • FigurePropertiesTest.m

  • IsSupportedTest.m

  • SolverTest.m


suiteFolder = TestSuite.fromFolder(pwd);
result = run(suiteFolder);


Create Simple Test Suites
Free download pdf