matlabtest.compiler.TestCase - Test case for deployed code artifact equivalence tests - MATLAB (original) (raw)

Main Content

Namespace: matlabtest.compiler
Superclasses: matlab.unittest.TestCase

Test case for deployed code artifact equivalence tests

Since R2023a

Description

Use the matlabtest.compiler.TestCase class to generate and test MATLAB® Compiler SDK™ deployed code artifacts for equivalence with MATLAB source code. Running equivalence tests for deployed code artifacts requires MATLAB Compiler SDK. This class inherits from matlab.unittest.TestCase.

The matlabtest.compiler.TestCase class is a handle class.

Creation

Create a class definition file that inherits from matlabtest.compiler.TestCase. Author test methods in a methods block to define the test case.

Examples

collapse all

This example shows how to generate a Python® package from MATLAB source code and test for equivalence by using MATLAB Compiler SDK.

The function makesquare generates an_n_-by-n matrix:

function y = makesquare(x) y = magic(x); end

This class definition file defines an equivalence test case that inherits from matlabtest.compiler.TestCase. The test case in the methods block defines a test case that:

  1. Builds the Python package from the makesquare function
  2. Executes the Python package with input set to 5
  3. Verifies the execution of the Python package against the execution of the MATLAB function makesquare with the same input

classdef tDeployment < matlabtest.compiler.TestCase methods(Test) function pythonEquivalence(testCase) buildResults = build(testCase,"makesquare.m", ... "pythonPackage"); executionResults = execute(testCase,buildResults,{5}); verifyExecutionMatchesMATLAB(testCase,executionResults); end end end

Run the pythonEquivalence test.

runtests("tDeployment", ... ProcedureName="pythonEquivalence")

Running pythonEquivalence .. Done pythonEquivalence


ans =

TestResult with properties:

      Name: 'tDeployment/pythonEquivalence'
    Passed: 1
    Failed: 0
Incomplete: 0
  Duration: 93.1237
   Details: [1×1 struct]

Totals: 1 Passed, 0 Failed, 0 Incomplete. 93.1237 seconds testing time.

Limitations

Version History

Introduced in R2023a