メインコンテンツ

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

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);
01-Feb-2025 15:00:31
Checking compatibility for test generation: model 'sldvSFCustomCodeExample'
Compiling model...done
Building model representation...done

01-Feb-2025 15:00:46

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

Generating tests using model representation from 01-Feb-2025 15:00:46...

..........
01-Feb-2025 15:00:54

Completed normally.

Generating output files:

01-Feb-2025 15:00:56
Results generation completed.

    Data file:
    /tmp/Bdoc25a_2864802_2141877/tp72286bef/sldv-ex18712703/sldv_output/sldvSFCustomCodeExample/sldvSFCustomCodeExample_sldvdata.mat

カバレッジの検証

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

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

クリーン アップ

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

close_system('sldvSFCustomCodeExample', 0);