Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.buildtool/
releases/
tbx/testframeworkextensionsdoc/*.html
tbx/testframeworkextensionsdoc/*.xml
tbx/testframeworkextensionsdoc/resources
tbx/testframeworkextensionsdoc/helpsearch-v4_en/
tbx/testextdoc/*.html
tbx/testextdoc/*.xml
tbx/testextdoc/resources
tbx/testextdoc/helpsearch-v4_en/
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="test"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
6 changes: 5 additions & 1 deletion tbx/testext/Contents.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% Test Framework Extensions
% Version 1.0.5 (R2026a) 16-Jun-2026
% Version 1.0.6 (R2026a) 13-Jul-2026
%
% Constraints
%
Expand All @@ -20,5 +20,9 @@
% PreferenceFixture
% SimulinkModelFixture
% SuppressParpoolAutocreateFixture
%
% Alias
%
% Testable

% Copyright 2026 The MathWorks, Inc.
4 changes: 4 additions & 0 deletions tbx/testext/Testable.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
classdef Testable < matlab.uitest.TestCase
%TESTABLE Convenience alias for matlab.uitest.TestCase.

end % classdef
4 changes: 4 additions & 0 deletions tbx/testextdoc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release notes

## Version 1.0.6

* Added `Testable` alias

## Version 1.0.5

* Added support for `code font` in release notes
Expand Down
88 changes: 88 additions & 0 deletions tbx/testextdoc/Testable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# `Testable`

Convenience alias for
[`matlab.uitest.TestCase`](https://www.mathworks.com/help/matlab/ref/matlab.uitest.testcase-class.html).

## Overview

`Testable` is a thin subclass of `matlab.uitest.TestCase`. It does not
add behavior, properties, or methods. Its purpose is to make UI test
classes shorter and easier to read.

Use `Testable` when you want the full UI testing API provided by
`matlab.uitest.TestCase`, including methods such as `press`,
`choose`, `type`, and `drag`.

## Example

```text
classdef tMyButton < Testable

methods ( Test )

function tPressButton( testCase )
clicked = false;
fig = uifigure();
testCase.addTeardown( @() delete( fig ) )

btn = uibutton( fig, ...
"Text", "Run", ...
"ButtonPushedFcn", @(~,~) onPress() );

testCase.press( btn )

testCase.verifyTrue( clicked )

function onPress()
clicked = true;
end

end

end

end
```

## Notes

- `Testable` is functionally equivalent to subclassing
`matlab.uitest.TestCase` directly.
- Use `matlab.unittest.TestCase` instead when the test does not require
UI interaction helpers.

## Testing UI Properties

When a UI class needs to expose handles for UI tests, keep those
properties read-only to production code and grant read access to
`Testable` subclasses.

```text
classdef MyView < matlab.ui.componentcontainer.ComponentContainer

properties ( GetAccess = ?Testable, SetAccess = private )
Button(:, 1) matlab.ui.control.Button {mustBeScalarOrEmpty}
Grid(:, 1) matlab.ui.container.GridLayout {mustBeScalarOrEmpty}
end

methods ( Access = protected )

function setup( obj )
obj.Grid = uigridlayout( obj, [1 1] );
obj.Button = uibutton( obj.Grid, "Text", "Run" );
end

end

end
```

This pattern lets UI tests inspect or interact with internal handles
while avoiding a wider public API. It also keeps mutation inside the
component implementation by pairing `GetAccess = ?Testable` with
`SetAccess = private`.

## See Also

- [`matlab.uitest.TestCase`](https://www.mathworks.com/help/matlab/ref/matlab.uitest.testcase-class.html)
- [`matlab.unittest.TestCase`](https://www.mathworks.com/help/matlab/ref/matlab.unittest.testcase-class.html)
4 changes: 3 additions & 1 deletion tbx/testextdoc/helptoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
* [GridLayoutFixture](GridLayoutFixture.md)
* [PreferenceFixture](PreferenceFixture.md)
* [SimulinkModelFixture](SimulinkModelFixture.md)
* [SuppressParpoolAutocreateFixture](SuppressParpoolAutocreateFixture.md)
* [SuppressParpoolAutocreateFixture](SuppressParpoolAutocreateFixture.md)
* [Alias]()
* [Testable](Testable.md)
3 changes: 3 additions & 0 deletions tbx/testextdoc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ The Test Framework Extensions toolbox provides custom [constraints](https://www.
* [`SimulinkModelFixture`](PreferenceFixture.md) - load a Simulink model and close it on teardown.
* [`SuppressParpoolAutocreateFixture`](SuppressParpoolAutocreateFixture.md) - suppress the automatic creation of parpools and restore the original setting in teardown.

### Alias
* [`Testable`](Testable.md) - alias for `matlab.uitest.TestCase`

The documentation provides examples of how to use these constraints and fixtures.