Programmatically close App Designer app after running it for a unit test
I need to run mlapp myApp for a unit test, but after the test I want the app window to be closed. The only way I know to do this is to search for the app UI Figure in all graphics objects, but I feel there should be a more elegant way.
In my example there is a function appStartup that is called by myApp when the app is started, and appStartup should throw an error if the app can’t be run. My code looks like:
function testAppNotRunnable(testCase)
% code here to make sure the app can’t run
verifyError(testCase, @() myApp, "appStartup:cantRunApp") % appStartup errors when called by myApp
% close open app windows
h = findall(groot, ‘Tag’, ‘my app tag’);
close(h)
This works, but seems inelegant.I need to run mlapp myApp for a unit test, but after the test I want the app window to be closed. The only way I know to do this is to search for the app UI Figure in all graphics objects, but I feel there should be a more elegant way.
In my example there is a function appStartup that is called by myApp when the app is started, and appStartup should throw an error if the app can’t be run. My code looks like:
function testAppNotRunnable(testCase)
% code here to make sure the app can’t run
verifyError(testCase, @() myApp, "appStartup:cantRunApp") % appStartup errors when called by myApp
% close open app windows
h = findall(groot, ‘Tag’, ‘my app tag’);
close(h)
This works, but seems inelegant. I need to run mlapp myApp for a unit test, but after the test I want the app window to be closed. The only way I know to do this is to search for the app UI Figure in all graphics objects, but I feel there should be a more elegant way.
In my example there is a function appStartup that is called by myApp when the app is started, and appStartup should throw an error if the app can’t be run. My code looks like:
function testAppNotRunnable(testCase)
% code here to make sure the app can’t run
verifyError(testCase, @() myApp, "appStartup:cantRunApp") % appStartup errors when called by myApp
% close open app windows
h = findall(groot, ‘Tag’, ‘my app tag’);
close(h)
This works, but seems inelegant. appdesigner, testing MATLAB Answers — New Questions