How do I control the execution of class-based unit tests using the coder.runTest function?
2 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2021 年 4 月 12 日
回答済み: MathWorks Support Team
2021 年 4 月 23 日
I am generating C/C++ code from my MATLAB code and I am verifying it using a set of class-based unit tests. Rather than running all of the tests in a given test class file, I would like to control which tests run when I call the coder.runTest function. How can I do that?
採用された回答
MathWorks Support Team
2021 年 4 月 12 日
There is a way you can do this using the coder.runTest function. See the steps below. This answer uses the same file names used in this example: Unit Test Generated Code with MATLAB Coder
1) Write a MATLAB script called "run_unit_tests.m" that you will use to run your tests
2) Inside "run_unit_tests.m", call the runtests function from the MATLAB Unit-Test Framework and use the "ProcedureName" Name-Value pair to specify which test you want to run. For instance, you could write:
>> runtests('TestAddOne','ProcedureName', 'reallyAddsOne')
See this link for more information on runtests: Run set of tests - MATLAB runtests
3) Now that you have your script setup, you can pass the name of the script to the coder.runTest function:
>> coder.runTest('run_unit_tests', ['addOne_sil.', mexext])
The coder.runTest function will run whatever code you write in "run_unit_tests.m", and so you can control exactly how the tests run.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Code Verification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!