Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

Stateflow チャートでのカスタム コードのテスト生成

この例では、Stateflow® チャートでの、カスタム コードをもつモデルに対するテスト生成の使用方法について説明します。

カスタム コードが含まれるモデルを Stateflow チャートで開く

open_system('sldvSFCustomCodeExample');

モデルのカバレッジを確認するテストの生成

関数 sldvrun を使用して、Simulink® Design Verifier™ 解析を実行します。

opts = sldvoptions;
opts.Mode = 'TestGeneration';
opts.ModelCoverageObjectives = 'ConditionDecision';
opts.SaveHarnessModel = 'off';
opts.SaveReport = 'off';

[status, fileNames] = sldvrun('sldvSFCustomCodeExample', opts);
03-Aug-2023 22:50:58
Checking compatibility for test generation: model 'sldvSFCustomCodeExample'
Compiling model...done
Building model representation...done

03-Aug-2023 22:51:18

'sldvSFCustomCodeExample' is compatible for test generation with Simulink Design Verifier.

Generating tests using model representation from 03-Aug-2023 22:51:18...

...........
03-Aug-2023 22:51:42

Completed normally.

Generating output files:

03-Aug-2023 22:51:44
Results generation completed.

    Data file:
    /tmp/Bdoc23b_2347338_3700083/tpd64437c5/sldv-ex18712703/sldv_output/sldvSFCustomCodeExample/sldvSFCustomCodeExample_sldvdata.mat

カバレッジの検証

関数 sldvruntest を使用して、テスト スイートがすべてのモデル カバレッジを達成することを検証します。

[~, finalCov] = sldvruntest('sldvSFCustomCodeExample', fileNames.DataFile, [], true);
cvhtml('Final Coverage', finalCov);

クリーン アップ

すべてのモデルを閉じて例を完了します。

close_system('sldvSFCustomCodeExample', 0);