test model against requirements and report results -凯发k8网页登录

main content

test model against requirements and report results

requirements – test traceability overview

traceability between requirements and test cases helps you interpret test results and see the extent to which your requirements are verified. you can link a requirement to elements that help verify it, such as test cases in the test manager, verify statements in a test sequence block, or model verification blocks in a model. when you run tests, a pass/fail summary appears in your requirements set.

this example demonstrates a common requirements-based testing workflow for a cruise control model. you start with a requirements set, a model, and a test case. you add traceability between the tests and the safety requirements. you run the test, summarize the verification status, and report the results.

requirements-based testing workflow

in this example, you conduct a simple test of two requirements in the set:

  • that the cruise control system transitions to disengaged from engaged when a braking event has occurred

  • that the cruise control system transitions to disengaged from engaged when the current vehicle speed is outside the range of 20 mph to 90 mph.

display the requirements

  1. open the example project.

    openexample("shared_vnv/cruisecontrolverificationprojectexample");
    pr = openproject("simulinkverificationcruise");
  2. in the models folder, open the simulinkcruiseaddreqexample model.

  3. display the requirements. click the icon in the lower-right corner of the model canvas, and select requirements. the requirements appear below the model canvas.

  4. display the verification and implementation status. right-click a requirement and select verification status and implementation status.

    property inspector and requirements implementation status for the model

  5. in the project window, open the simulink® test™ file slreqtests.mldatx from the tests folder. the test file opens in the test manager.

link requirements to tests

link the requirements to the test case.

  1. in the project window, open the simulink test file slreqtests.mldatx from the tests folder. the test file opens in the test manager. explore the test suite and select safety tests.

    return to the model. right-click on requirement s 3.1 and select link from selected test case.

    a link to the safety tests test case is added to verified by. the yellow bars in the verified column indicate that the requirements are not verified.

    requirement dialog box showing linked tests to specific requirements

  2. also add a link for item s 3.4.

run the test

the test case uses a test harness safetytest_harness1. in the test harness, a test sequence sets the input conditions and checks the model behavior:

  • the braketest sequence engages the cruise control, then applies the brake. it includes the verify statement

    verify(engaged == false,...
        'verify:brake',...
        'system must disengage when brake applied')
  • the limittest sequence engages the cruise control, then ramps up the vehicle speed until it exceeds the upper limit. it includes the verify statement.

    verify(engaged == false,...
        'verify:limit',...
        'system must disengage when limit exceeded')
  1. return to the test manager. to run the test case, click run.

  2. when the test finishes, review the results. the test manager shows that both assessments pass and the plot provides the detailed results of each verify statement.

    test results for verify statements

  3. return to the model and refresh the requirements. the green bar in the verified column indicates that the requirement has been successfully verified.

    verified status for requirements

report the results

  1. create a report using a custom microsoft® word template.

    1. from the test manager results, right-click the test case name. select create report.

    2. in the create test result report dialog box, set the options:

      • title — safetytest

      • results for — all tests

      • file format — docx

      • for the other options, keep the default selections.

    3. enter a file name and select a location for the report.

    4. for the template file, select the reporttemplate.dotx file in the documents project folder.

    5. click create.

  2. review the report.

    1. the test case requirements section specifies the associated requirements

    2. the verify result section contains details of the two assessments in the test, and links to the simulation output.

related topics

  • (simulink test)

external websites

    网站地图