matlab.unittest.fixtures.Fixture class

Package: matlab.unittest.fixtures

Interface class for test fixtures

Description

The Fixture interface class is the means by which test authors create custom fixtures. Fixtures configure the environment state required for tests.

Classes deriving from the Fixture interface must implement the setup method. This method executes the changes to the environment. A fixture should restore the environment to its initial state when it is torn down. To restore the environment, use the addTeardown method in the setup method or implement the fixture’s teardown method.

Subclasses can set the SetupDescription and TeardownDescription properties in their constructors to provide descriptions for the actions performed by the setup and teardown methods. The testing framework can display these descriptions when setting up and tearing down the fixture.

A class that derives from Fixture must implement the isCompatible method if its constructor accepts any input arguments or is otherwise configurable. Fixture subclasses use this method to define a notion of interchangeability of fixtures. Two matlab.unittest.fixtures instances of the same class are considered to be interchangeable if the isCompatible method returns true. The TestRunner uses the result of isCompatible to determine whether two fixture instances of the same class correspond to the same shared test fixture state.

Properties

SetupDescription

Description of fixture setup actions, specified as a character vector. The SetupDescription property describes the actions the fixture performs when the testing framework invokes the fixture’s setup method.

TeardownDescription

Description of fixture teardown actions, specified as a character vector. The TeardownDescription property describes the actions the fixture performs when the testing framework invokes the fixture’s teardown method.

Methods

addTeardownDynamically add teardown routine to Fixture instance
applyFixtureSet up fixture to delegate work to another fixture
isCompatibleDetermine if two fixtures of the same class are interchangeable
logRecord diagnostic information during fixture setup and teardown
needsReset Report whether shared test fixture needs to be reset
onFailureDynamically add diagnostics for failures during fixture setup and teardown
setupSet up fixture
teardownTear down fixture

Events

AssertionFailed

Triggered upon failing assertion. A QualificationEventData object is passed to listener callback functions.

AssertionPassed

Triggered upon passing assertion. A QualificationEventData object is passed to listener callback functions.

AssumptionFailed

Triggered upon failing assumption. A QualificationEventData object is passed to listener callback functions.

AssumptionPassed

Triggered upon passing assumption. A QualificationEventData object is passed to listener callback functions.

FatalAssertionFailed

Triggered upon failing fatal assertion. A QualificationEventData object is passed to listener callback functions.

FatalAssertionPassed

Triggered upon passing fatal assertion. A QualificationEventData object is passed to listener callback functions.

ExceptionThrown

Triggered by the TestRunner when an exception is thrown. An ExceptionEventData object is passed to listener callback functions.

DiagnosticLogged

Triggered by the TestRunner upon a call to the log method. A LoggedDiagnosticEventData object is passed to the listener callback functions.

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.