How to test a function containing "waitfor" function without external user input?

60 次查看(过去 30 天)
I am testing my GUI functions. I am using Java functions in my test class to trigger mouse clicks. It will trigger a popup dialogue. Here the function pauses at the line of "waitfor". I have to manually click a button to close the dialogue, so the code running can continue. How can I make this process fully automatic?
  1 个评论
Walter Roberson
Walter Roberson 2024-11-18,5:50
I think I once saw someone simulate pressing buttons through MATLAB Tester... but I cannot seem to find any way to do that at the moment.

请先登录,再进行评论。

采纳的回答

Madheswaran
Madheswaran 2024-11-18,9:46
Hi,
Starting from MATLAB R2024b, you can programmatically interact with alert and confirmation dialog boxes using 'chooseDialog' and 'dismissDialog' methods. They work with both modal and non-modal dialogs and can automatically select options or close dialogs without manual intervention.
For more information and examples, refer to the following documentations:
  1. dismissDialog - https://mathworks.com/help/matlab/ref/matlab.uitest.testcase.dismissdialog.html
  2. chooseDialog - https://mathworks.com/help/matlab/ref/matlab.uitest.testcase.choosedialog.html
Hope this helps!

更多回答(1 个)

埃博拉酱
埃博拉酱 2024-11-18,9:20
Possible ideas:
  1. Create a waitfor function for testing in the current directory before testing to see if it can mask the waitfor of MATLAB.
  2. Create an environment or a global variable with a special name (such as YourAppName_Debug) before the test, check whether the environment variable exists in the test objective function, and skip the dialog box if it exists.
  3. Add an undocumented optional parameter to the function. This parameter is only offered by the developer in the test environment.

类别

Help CenterFile Exchange 中查找有关 Outputs 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by