Main Content


Class: matlab.unittest.plugins.QualifyingPlugin
Namespace: matlab.unittest.plugins

Verify that value satisfies given constraint




verifyUsing(plugin,context,actual,constraint) verifies that actual is a value that satisfies the given constraint, constraint, using the qualification context. If the actual value does not satisfy the constraint, the testing framework reports a verification failure.

You can perform verifications in these QualifyingPlugin methods:

  • setupTestClass

  • teardownTestClass

  • setupTestMethod

  • teardownTestMethod

verifyUsing(plugin,context,actual,constraint,diagnostic) displays the diagnostic information, diagnostic, upon failure.

Input Arguments

expand all

Plugin instance, specified as an instance of the matlab.unittest.plugins.QualifyingPlugin class.

Context for plugins, specified as an instance of matlab.unittest.plugins.plugindata.QualificationContext class. This instance provides the context for the plugin to perform qualifications on test suites. The plugin obtains this context from the plugin data.

Value to test, specified as a workspace variable. actual can be any data type. The qualification passes when actual satisfies the specified constraint, constraint.

Condition the test must satisfy, specified as an instance of a class in the matlab.unittest.constraints namespace.

Diagnostic information to display upon failure, specified as a string, a character vector, a function handle, or an instance of a class in the matlab.unittest.diagnostics namespace.


Use Qualifications in Plugin

See examples for the QualifyingPlugin class.


Use the QualifyingPlugin.verifyUsing method to produce and record failures without throwing an exception. Because a QualifyingPlugin performs additional qualifications beyond the ones defined in the unit tests, it typically uses verifications. Verifications do not cause an early exit from the test, ensuring that the test framework executes all test content. Use other qualification types to test for violation of preconditions or incorrect test setup. Alternatively,

  • Use the QualifyingPlugin.assumeUsing method to ensure that the test environment meets preconditions that otherwise do not result in a test failure. Assumption failures result in filtered tests, and the testing framework marks the tests as Incomplete.

  • Use the QualifyingPlugin.assertUsing method when the failure condition invalidates the remainder of the current test content, but does not prevent proper execution of subsequent test methods. A failure at the assertion point renders the current test method as failed and incomplete.

  • Use the QualifyingPlugin.fatalAssertUsing method to abort the test session upon failure. These qualifications are useful when the failure mode is so fundamental that there is no point in continuing testing. These qualifications are also useful when fixture teardown does not restore the MATLAB® state correctly and it is preferable to abort testing and start a fresh session.

Version History

Introduced in R2015b