I got 'Invalid or deleted object.' from app designer.

22 views (last 30 days)
I am trying to create a app Test Class with app test framework.
I wrote below code,
classdef TestModelVerificationApp < matlab.uitest.TestCase
properties
App
end
methods (TestClassSetup)
% Shared setup for the entire test class
end
methods (TestMethodSetup)
% Setup for each test
function launchApp(testCase)
testCase.App = ModelVerificationApp;
testCase.addTeardown(@delete,testCase.App);
end
end
methods (Test)
% Test methods
function test_bttn_select(testCase)
% Click Button_Select Button
testCase.press(testCase.App.Button_Run)
% Verify selected model has been updated
testCase.verifyEqual(testCase.App.ListBox_SelectedModels.Items,'test item')
end
function unimplementedTest(testCase)
testCase.verifyFail("Unimplemented test");
end
end
end
for test below app. Below is a beginning part of the app, 'ModelVerificationApp'
classdef ModelVerificationApp < matlab.apps.AppBase
properties (Access = public)
ModelAdvisorAppUIFigure matlab.ui.Figure
ModelAdvisorPanel matlab.ui.container.Panel
Button_Run matlab.ui.control.Button
And, when I try to test this, I got below error message.
================================================================================
Error occurred in ModelVerificationApp/test_bttn_select and it did not run to completion.
---------
Error ID:
---------
'MATLAB:class:InvalidHandle'
--------------
Error Details:
--------------
Invalid or deleted object.
Error in TestModelVerificationApp/test_bttn_select (line 24)
testCase.press(testCase.App.Button_Run)
================================================================================
Anyone can tell me why?
Thanks.

Accepted Answer

호동
호동 on 16 Feb 2023
Moved: Voss on 23 Aug 2023
Okay,
I've figured it out by myself.
The issue was accured because there was a existing app running.
So, when I tried to get the its handle, it encountered the handle isssue.

More Answers (0)

Categories

Find more on Results, Reporting, and Test File Management in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!