Main Content


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

Create a TestCase object for interactive use



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.

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])
Verification passed.
Introduced in R2018a