This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Class: matlab.uitest.TestCase
Package: matlab.uitest

Create a TestCase object for interactive use


tc = matlab.uitest.TestCase.forInteractiveUse


tc = matlab.uitest.TestCase.forInteractiveUse creates a matlab.uitest.TestCase instance for interactive use. The TestCase is configured so you can experiment with it at the MATLAB® command prompt. The TestCase reacts to qualification failures and successes by displaying messages to the screen for both passing and failing conditions.


expand all

Create a red lamp component that changes to green when a button is pressed.

fig = uifigure;
lamp = uilamp(fig,'Position',[50 100 20 20],'Color','red');
button = uibutton(fig,'ButtonPushedFcn',@(btn,event) set(lamp,'Color','green'));

Create a TestCase object configured for interactive use at the MATLAB command prompt.

tc = matlab.uitest.TestCase.forInteractiveUse;

Press the button.

Verify the lamp color is green. This test fails because the lamp stores color as an RGB triplet.

Interactive verification failed.

Framework Diagnostic:
verifyEqual failed.
--> Classes do not match.
    Actual Class:
    Expected Class:

Actual Value:
     0     1     0
Expected char:

Verify the lamp color is the RGB triplet for green.

tc.verifyEqual(lamp.Color,[0 1 0])
Interactive verification passed.

Introduced in R2018a