In MATLAB, you can create a test class to define a suite of tests, and it is possible to define setup and teardown methods to prepare the environment before and after each test case. To load a project before running any tests and close the project after all tests have run, you can define the following methods in your test class:
main.m667 chars28 lines
In this example, the loadProject
method is decorated with the TestMethodSetup
attribute, which means that it is executed once before each test method. This method loads the project using the loadProject
function, and stores a handle to the project in a property of the test class.
Similarly, the closeProject
method is decorated with the TestMethodTeardown
attribute, which means that it is executed once after each test method. This method simply closes the project by calling the close
function on the project handle.
You can then define your test methods as usual, and they will automatically have access to the loaded project.
gistlibby LogSnag