Using Signal Logging for Test Harness to Matlab Workspace

2 次查看(过去 30 天)
I am using a simple script to run a test case via a test harness within Matlab
%% Clear Workspace
clc
close all
clear
%% Run Test Cas(es)
out = runtests(Name='my test case');
logsouttest = out.logsout;
This errors on line 9
The 'runtests' command does not export like the 'sim' command. But I can't use the 'sim' command since I am using a test harness and need to utilize the 'runtests' command.
I know there has to be a way to get the 'logsout' data, I just cannot figure out the syntax.
Overall goal is to get the logged signal data in the test harness into the Matlab workspace

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2023-12-21
doc matlab.unittest.TestResult
help matlab.unittest.TestResult
TestResult - Result of running a test suite The matlab.unittest.TestResult class holds the information describing the result of running a test suite using the matlab.unittest.TestRunner. It contains information describing whether the test passed, failed, or ran to completion as well as the duration of the tests. TestResult arrays are created and returned by the test runner, and are of the same size as the suite which was run. TestResult properties: Name - The name of the TestSuite for this result Passed - Logical value showing if the test passed Failed - Logical value showing if the test failed Incomplete - Logical value showing if test did not run to completion Duration - Time elapsed running test Details - Structure containing custom data for this result TestResult methods: table - Convert TestResult object to table assertSuccess - Assert test session runs without failure Examples: >> import matlab.unittest.TestSuite; >> % Result display method provides a summary of the results >> suite = TestSuite.fromClass(?SomeTestClass) >> results = run(suite) results = 1x16 TestResult array with properties: Name Passed Failed Incomplete Duration Details Totals: 12 Passed, 4 Failed (rerun), 0 Incomplete. 5.5091 seconds testing time. >> >> % Rerun only the failed tests by clicking the "rerun" hyperlink ans = 1x4 TestResult array with properties: Name Passed Failed Incomplete Duration Details Test Suite Summary: 0 Passed, 4 Failed (rerun), 0 Incomplete. 1.2894 seconds testing time. >> % Make the fix and rerun the failed tests ans = 1x4 TestResult array with properties: Name Passed Failed Incomplete Duration Details Test Suite Summary: 4 Passed, 0 Failed, 0 Incomplete. 1.1607 seconds testing time. See also: TestSuite, TestRunner Documentation for matlab.unittest.TestResult doc matlab.unittest.TestResult
  2 个评论
Tim Proby
Tim Proby 2023-12-21
that gets me the results of the test (e.g. pass or fail) but not the logged signals that are generated during the test
I want to get the signals that are generated (e.g. position, velocity, acceleration) over time
Tim Proby
Tim Proby 2023-12-21
移动:madhan ravi 2023-12-21
To clarify, I want the "Sim Outputs" in my Matlab workspace

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Outputs 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by