To create a test class that loads a project before running any tests in MATLAB, you can use the matlab.unittest.TestCase
class provided by the matlab.unittest
testing framework. Here's an example implementation:
main.m481 chars20 lines
In this example, the loadProject
method is decorated with the TestClassSetup
attribute, which means it will be executed once before any of the test methods are run. Inside this method, we call a hypothetical runProject
function that loads the project we want to test.
After the project is loaded, we define a testSomething
method decorated with the Test
attribute. This method contains some test logic that calls a hypothetical myFunction
and verifies that its output is equal to an expected value.
When we run this test class, the loadProject
method will be executed first, which will load the project we want to test. Then, the testSomething
method will be executed, which will perform our tests on the loaded project.
gistlibby LogSnag