test sequence basics -凯发k8网页登录

main content

test sequence basics

a test sequence consists of test steps arranged in a hierarchy. you can use a test sequence to define test inputs and to define how a test will progress in response to the simulation. a test step contains actions that execute at the beginning of the step. a test step can contain transitions that define when the step stops executing, and which test step executes next. actions and transitions use matlab® as the action language. you create test sequences by using the block and the . see .

test sequence hierarchy

test sequences defined in test sequence blocks can have parent steps and substeps. substeps can activate only if the parent step is active. a group of steps in the same hierarchy level shares a common transition type. when you create a test step, the step becomes a transition option for other steps in the same group.

test sequence scenarios

in a test sequence block, you can define multiple test sequences, which are called test sequence scenarios. by using scenarios, you can define distinct test sequences without having multiple test sequence blocks in your test harness. you can run test sequence scenarios in these ways:

  • activate a single scenario from the test sequence editor and run the model

  • activate a single scenario using api commands and run the model

  • control the active scenario with a workspace variable and run the model

  • use a custom test script to loop through scenarios when running the model

  • define iterations in the test manager to run more than one scenario in a single test case

for more information and examples of using test sequence scenarios, see use test sequence scenarios in the test sequence editor and test manager and .

transition types

test sequences defined in test sequence blocks transition from one step to another in two ways:

  • standard transition: you can define a sequence of actions that react to simulation conditions using a standard transition sequence. standard transition sequences start with the first step and progress according to transition conditions and next steps. for a list of transitions, see .

    this test sequence sets the value of boolean outputs redbuttonin and greenbuttonin, with transitions happening after each step has been active for 1 sec.

    test sequence steps, transitions, and next steps

  • when decomposition: when decomposition sequences are analogous to switch statements in programming. your sequence can act based on specific conditions occurring in your model. in a when decomposition sequence, steps activate based on a condition that you define after the step name. transitions are not used between steps.

    this when decomposition contains three verify statements. each verify statement is active when the signal gear is equal to a different value. for more information, see .

    test sequence using when decomposition

create a basic test sequence

in this example, you use a test sequence block to create a simple test sequence for a transmission shift logic controller.

  1. open the model. at the command line, enter

    openexample('transmissiondownshifttestsequence')
  2. right-click the shift_controller subsystem and select test harness > create for ‘shift_controller’.

  3. in the create test harness dialog box, under sources and sinks:

    • select test sequence from the source drop-down menu.

    • select add separate assessment block.

    • select open harness after creation.

  4. click ok. the test harness for the shift_controller subsystem opens.

  5. double-click the test sequence block. the test sequence editor opens.

    test sequence editor with default step

  6. create the test sequence.

    1. rename the first step accelerate and add the step actions:

      speed = 10*ramp(et);
      throttle = 100;
    2. right-click the accelerate step and select add step after. rename this step stop, and add the step actions:

      throttle = 0;
      speed = 0;
    3. enter the transition condition for the accelerate step. in this example, accelerate transitions to stop when the system is in fourth gear for 2 seconds. in the transition column, enter:

      duration(gear == 4) >= limit

      in the next step column, select stop.

    4. add a constant to define limit. in the symbols pane, hover over constant and click the add data button. enter limit for the constant name.

    5. hover over limit and click the edit button. in the constant value field, enter 2. click ok.

    test sequence editor with defined steps, transition, and next step

create basic test assessments

  1. continuing the example, in the test harness, double-click the test assessment block to open the editor. the editor displays a when decomposition sequence.

  2. rename the first step assessments.

  3. add two steps to assessments. right-click the assessments step and select add sub-step. do this a second time. there should be four steps under assessments.

  4. enter the names and actions for the four substeps.

    check1st when gear == 1
    verify(speed < 45)
    check2nd when gear == 2
    verify(speed < 75)
    check3rd when gear == 3
    verify(speed < 105)
    else

    test sequence editor with assessments and verify statements

    the fourth step else has no actions. else handles simulation conditions outside of the preceding when conditions.

  5. add a scope to the harness and connect the speed, throttle, and gear signals to the scope.

    test harness with test sequence and test assessment blocks

  6. set the model simulation time to 15 seconds and simulate the test harness. view the signal data by opening the scope.

    signal data plots

  7. view the results of the verify statements in the simulation data inspector.

    plots of verify statements results

see also

related topics

网站地图