This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

matlab.unittest.constraints.Constraint class

Package: matlab.unittest.constraints

Fundamental interface class for comparisons


The Constraint interface class is the means by which matlab.unittest constraints encode comparison logic and the corresponding diagnostic information. Every comparison that conditionally can produce a failure inherits from the Constraint interface class.

Classes deriving from the Constraint interface class must provide a means to determine if a given value satisfies the constraint. To do this, implement the satisfiedBy method, which includes the definition of the underlying comparison logic. Classes deriving from the Constraint class also must provide a diagnostic for any given actual value. The testing framework uses the diagnostic when it encounters a qualification failure. To do this, implement the getDiagnosticFor method.

In exchange for meeting these requirements, all Constraint implementations are easily used with all qualification types through the verifyThat, assertThat, assumeThat, or fatalAssertThat methods. The qualifications use the comparison and diagnostic knowledge contained within the constraints. Also, the constraints can be used in situations where a test failure is not wanted, but the testing framework needs to reuse the comparison logic. For example, a constraint implementation may want to use the logic defined inside of another constraint. Since the constraint can interact with the other constraint directly, it can use the logic without the potential of causing a qualification failure.


getDiagnosticForProduce diagnostic for compared value
satisfiedByDetermine whether value satisfies constraint

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.

Was this topic helpful?