www.gusucode.com > simulinktest 案例源码程序 matlab代码 > simulinktest/BasicSLTestMLUnitWorkflowExample.m
%% Basic Workflow Using MATLAB(R) Unit Test % This example shows how to create and run a basic MATLAB(R) Unit Test for % a test file created in Simulink(R) Test(TM). You create % a test suite, run the test, and display the diagnostic report. %% % 1. Author a test file in the Test Manager, or start with a preexisting % test file. For this example, |AutopilotTestFile| tests a component % of an autopilot system against several requirements, using |verify| % statements. % % 2. Create a |TestSuite| from the test file. % % apsuite = testsuite('AutopilotTestFile.mldatx'); % apsuite apsuite = testsuite('AutopilotTestFile.mldatx'); apsuite %% warning off Stateflow:Runtime:TestVerificationFailed; warning off Stateflow:cdr:VerifyDangerousComparison; %% % 3. Run the test, creating a |TestResult| object. The command window % returns warnings from the |verify| statement failures. % % apresults = run(apsuite); apresults = run(apsuite); %% % 4. To view the details of the test, display the |Report| property of the % |DiagnosticRecord| object. The record shows that a verification failed % during the test. % % apresults.Details.DiagnosticRecord.Report apresults.Details.DiagnosticRecord.Report %% warning on Stateflow:Runtime:TestVerificationFailed; warning on Stateflow:cdr:VerifyDangerousComparison;