coder.runTest
Run test replacing calls to MATLAB functions with calls to MEX functions
Description
coder.runTest( runs test,fcn)test replacing
calls to fcn with calls to the compiled version
of fcn. test is the file
name for a MATLAB® function, script, or class-based unit test
that calls the MATLAB function fcn. The
compiled version of fcn must be in a MEX function
that has the default name. The default name is the name specified
by fcn followed by _mex.
coder.runTest( replaces
a call to a MATLAB function with a call to the compiled version
of the function when the compiled version of the function is in test,mexfile)mexfile. mexfile includes
the platform-specific file extension. If mexfile does
not contain the compiled version of a function, coder.runTest runs
the original MATLAB function. If you do not want to specify the
individual MATLAB functions to replace, use this syntax.
Examples
Input Arguments
Tips
coder.runTestdoes not return outputs. To see test results, in the test, include code that displays the results.To compare MEX and MATLAB function behavior:
Run the test in MATLAB.
Use
codegento generate a MEX function.Use
coder.runTestto run the test replacing the call to the original function with a call to the compiled version in the MEX function.
Before using
coder.runTestto test multiple functions, compile the MATLAB functions into a single MEX function.If you use the syntax
coder.runTest(test, mexfile), usemexextto get the platform-specific MEX file name extension. For example:coder.runTest('my_test', ['mymexfun.', mexext])
If errors occur during the test, you can debug the code using call stack information.
You can combine MEX generation and testing in one step by running
codegenwith the-testoption. For example, the following code generates a MEX function formyfunctionand calls the test filemyfunction_test, replacing calls tomyfunctionwith calls tomyfunction_mex.codegen myfunction -test myfunction_test
Version History
Introduced in R2012a