How do I use matlab.uitest.TestCase to open my app once and perform multple function tests?
5 views (last 30 days)
Show older comments
I'm using matlab.uitest.TestCase to test my app. I'm looking for a way to launch my app only once and then perform a variety of tests defined under methods (Test)
0 Comments
Accepted Answer
Steven Lord
on 26 Jan 2023
You could do this by opening your app in a TestClassSetup method and storing a handle to it in a property of your test class, but this could lead to your tests violating the "Keep Tests Independent" principle.
Suppose you had two buttons, A and B. You want to unit test both buttons. So you write one test method named testA that clicks button A and another named testB that clicks button B. But the code that executes when you click button A disables button B. Depending on the order in which testA and testB run and whether or not they restore the state of the app back to how it was before they ran, testB may or may not fail. And if you tried to reproduce the failure (to investigate the root cause) by just running testB it would pass.
Heisenbugs are highly annoying to investigate.
More Answers (0)
See Also
Categories
Find more on Function-Based Unit Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!