Create Test Cases, Signals, and Buses

Navigate in the Test Case Editor

The Test Case Editor has two views you can work in. By default it opens in the Edit view. You can switch between the two views using the Test Case View and Edit View buttons on the top right of the tool. In the following diagram, the Edit View button is selected.

You edit and work with signals in the Edit view. The Test Case view offers easy navigation when you have many signals in a test case.

Edit View

The Edit view shows plots of the selected signals in a test case. Select a test case in the Test Case list to see its signals in the Edit view. Only one test case at a time can be selected.

In the lower-left pane is a signal list that lists every signal in the selected test case. You can click signals in the signal list to select or clear them. You can select multiple signals by using the Ctrl key as you click on them.

Only signals that are selected in the signal list are shown in the signal display area. If all signals are selected, all the signals' plots will be displayed in the signal display area. A scroll bar appears if the signal plots take up more vertical room than is available in the signal display area.

In the signal display area, only one signal at a time can be selected. The plot of the currently selected signal is outlined in yellow. Properties shown in the Signal Properties section are the values for the currently selected signal. For information on setting signal properties, see step 4 in Add Signals to Test Cases.

Properties shown in the Segment Properties section are the values for the currently selected segment inside the selected signal. The diagram to the right of the properties shows graphical definitions of the values of the signal type. For information on setting segment properties, see steps 5 through 8 in Add Signals to Test Cases.

Test Case View

The Test Case view shows an icon for each signal in the selected test case. The shape of the signal and its name are shown. The signals are displayed from left to right across each row and then continue in the next row down, in the order of creation. A scroll bar appears if the icons use more vertical room than is available in the view area.

In the Test Case view, multiple signals can be selected. The signal icons that are selected are shown with a dark blue background. Unselected signals have a white background.

This view allows an easy way to find and manage signals when you have many signals in a test case. It is easier to locate a signal by looking at the graphics in this view. It is also easy to add and delete signals in this view. As in the Edit view, click the Add Signal button to add a signal in the Test Case view. If you want to edit the signal, you must return to the Edit view, by double-clicking the signal or by clicking the Edit View button. You can delete a signal in this view by selecting its icon and pressing the Delete key.

If you have a large number of signals, use the slider at the bottom of the Test Case view to adjust the size of the graphics, which in turn determines how many are shown at once. Sliding the bar to the left shrinks the size of the graphics and displays more of them. Sliding the bar to the right increases the size of the graphics and shows less of them.

When you click the Edit View button to return to the Edit view, the first signal that is selected in the Test Case view will be selected in the Edit view and its plot will be displayed in the edit area.

Create Test Cases

When the Test Case Editor is opened from the Test Case Data test vector in the SystemTest™ desktop, it opens in the Edit view and contains one test case called TestCase1 by default.

There are two workflows you could follow. You can add multiple test cases, and then go into each test case and add the signals, or you could add one test case and then add the signals to it, and then add another test case and its signals if you have multiple test cases. Both of these workflows are described below.

To add test cases one at a time with their signals:

  1. Rename the default test case, by double-clicking TestCase1 in the Test Cases list.

  2. Type a new name for the first test case and press Enter to change the name.

  3. With the renamed test case selected, edit it to add signals, as described in Add Signals to Test Cases.

  4. Once the first test case is configured, if you need multiple test cases, click the Add Test Case button to add a second test case.

  5. When creating a new test case, you have the option of populating it with signals from another test case, or with constant values of 0. In this case, your first test case contains signals with values that you set, so you may want to use the second option, The same signal values specified in the following test case, and then select the first test case in the drop-down list. You can then edit the new test case to vary it from the first. This option is useful to duplicate values from another test case. If you do not want to start out with the same signals, select the other option, A constant value of 0.

    Click OK.

  6. Add signals to the second test case and/or modify signals that it already contains.

  7. Repeat these steps as necessary to create more test cases.

To add multiple test cases and then signals:

  1. Rename the default test case, by double-clicking TestCase1 in the Test Cases list.

  2. Type a new name for the first test case and press Enter to change the name.

  3. Click the Add Test Case button to add a second test case.

      Note:   All test cases must have the same number of signals as well as the same set of names for their signals. For example if TestCase1 has signals named SignalA and SignalB, when you create a new test case TestCase2, it will be populated with two signals named SignalA and SignalB. The two sets of signals may have different parameters and values set though.

  4. When creating a new test case, you have the option of populating it with signals from another test case, or with constant values of 0. In this case the first test case's signal has not been modified yet, so keep the default option A constant value of 0, and click OK.

  5. Rename the second test case by double-clicking its default name, typing a new name, and pressing Enter.

  6. Repeat these steps to add as many test cases as you need.

  7. When the test cases are present, add signals to each one by selecting it in the Test Cases list and then editing it as described in Add Signals to Test Cases.

To delete a test case, select it in the Test Cases list and press the Delete key, or right-click and select Delete from the context menu.

Test Case Options

You can set options for the test case by right-clicking on a test case in the Test Cases list, and selecting Options from the context menu. This opens the Test Case Options dialog box.

To determine test case length:

In order to run a test using the test cases you created, all signals within a test case must be the same length. In case some signals are shorter than others, use the following options to determine how to define the end time for all signals in the test case.

  • Extend all signals to the longest time means that all the signals will be extended to the length of the longest signal. For example, if you have four signals of length 3, 5, 7, and 7, the signals of length 3 and 5 will both be extended to 7 seconds.

    Note that when a signal is extended, it is extended in the way that you select in the Extrapolation Policy property in the Signal Properties of a given signal. See step 4 in Add Signals to Test Cases for more information on setting that property.

  • If you select End all signals at n seconds, use the arrows to choose the length that you want all signals to use. Every signal in the test case then ends at that time in seconds.

Description

You can optionally add a description for the test case here. Enter your text in the text field and it is saved when you click OK.

Add Signals to Test Cases

You build test cases in the Test Case Editor by adding signals to them. The test cases are then used in the Test Case Data test vector, through the Simulink element in the SystemTest software. The tool supports the following signal types: constant, ramp, step, pulse, square, sine, and custom.

For information on opening the Test Case Editor from the SystemTest software, see Author and Use Signals in Tests. For information on creating test cases, see Create Test Cases.

To create signals:

  1. In the Test Case list, select the test case you want to populate.

    By default, the first time you open the tool from a new Test Case Data test vector, one test case is created.

  2. The test case that is created by default contains one signal when it is created. You can modify that signal and use it as your first signal, or delete it.

  3. For additional signals, click the Add Signal button that appears above the signal list in the lower-left pane.

    Select the type of signal to add from the drop-down button. For information about the parameters and constraints of each signal type, see Signal Types.

    If you have only one test case, the new signal is added underneath whatever signal is currently selected in that test case.

    If there are multiple test cases, you are prompted with the Add New Signal dialog box. Since all test cases need to contain the same signals, the new signal will also be added to all other test cases. Select the value to propagate to the other test case(s), then click OK.

  4. Set the signal properties for the signal. These are set in the Signal Properties section underneath the signal plots.

    You can edit signal properties for the selected signal, as follows:

    Name — New signals are given a default name. Type a new name in the edit field.

    Data Type — New signals are data type double by default. Accept the default or select a different data type from the list of standard MATLAB data types.

    Changing the data type changes the value of the signal. Note that if you change the data type, the change will be applied at run time of the test, but will not be visually reflected in the Test Case Editor – the Editor's user interface will display the signal as if it were still data type double in the signal plot in the Edit view, as well as the plot icon in the Test Case view. When you run the test, the values that are used will reflect the data type that is set.

    Extrapolation Policy — All the signals in a test case must have the same length. If this signal is shorter than the longest signal, this option determines what value is used to lengthen it. Hold last value as a constant means that the end value of the signal's last segment will be held as a constant for the rest of the time. Selecting Bring back to zero and hold drops the signal to 0 after the last segment ends.

    Property edits are committed when you press Enter or click outside of the edit field.

  5. When you add a signal, it will contain one segment and use default values for that signal type. Set values for the selected segment in the Segment Properties section. Each type of signal has a different set of properties to set. For example, a constant has only Segment Duration and Value properties, and a pulse has properties for Segment Duration, Initial Value, Offset, Final Value, and Pulse Width.

    For information about the parameters and constraints of each signal type, see Signal Types.

    As you set values in the Segment Properties section, they are committed and immediately reflected in the plot of the signal when you click outside of a field or press Enter.

  6. Signals contain one segment by default but you can append multiple segments to define your signal. You can create a signal by concatenating together any of the supported signal types as segments. The contiguous segments make up the entire signal's value.

    To append a segment to the selected signal, click the Append button in the signal plot. Select a signal type for the new segment from the drop-down list.

    The Append button and the arrow buttons only appear in the plot of the currently selected signal. A signal can be selected by clicking it when in the Edit view.

    The new segment is appended to the end of the currently selected segment, and uses default values for that signal type.

  7. Edit the Segment Properties for the new segment. Each segment has its own properties and any edits made will be applied to the currently selected segment.

    See Signal Concatenation for information on the rules that govern concatenation.

  8. While editing a signal with multiple segments:

    • The currently selected segment is highlighted with a blue line in the plot. Click a segment to select it.

    • You can use the left and right arrow buttons in the plot to move the currently selected segment.

    • Increasing or decreasing a segment's length results in shifting the other segments of the signal as well. (However, it does not change their lengths.)

    • You can delete the currently selected segment by pressing the Delete key.

    • Note that if you set the Extend all signals to the longest time option in the Test Case Options, when you make the current signal longer by adding a segment, any other signals in the test case will be extended to the same length, using the Extrapolation Policy you selected in the Signal Properties. In the other signal(s), the additional length is shown as a dotted line in its plot.

  9. Repeat these steps to add as many segments to a signal as necessary.

Signal Concatenation

You can create a signal by concatenating any of the supported signal types as segments. The contiguous segments make up the entire signal's value. The following rules apply:

  • The first segment's start time is 0.

  • Any other segments' start time is the same as the end time of the previous segment.

  • The length of a segment is its duration.

  • The end time of a segment is its start time + duration.

  • The length of a signal is the sum of the duration of all of the segments.

When the duration of a segment changes, it has no effect on the duration of any other segments. The length of the other segments remains the same. The length of the entire signal changes however, because one of its segments became shorter or longer.

If a segment is added or deleted from a signal, this has no effect on neighboring segments' parameters. Individual segments remain the same length but the signal length changes as a result.

Buses in the Test Case Editor

The Test Case Editor supports the use of buses in your model and you can use it to create buses and signals within buses.

The hierarchy of buses and signals appears in the signal list in the lower-left pane of the Test Case Editor, as shown here in the Edit view.

In this example you can see that In1 is a bus containing two signals, pressure and temperature. The signal pressure is selected in the signal tree and consequently is displayed and selected in the editing pane, when in the Edit view.

Nested bus hierarchies are supported. In the example you can see that bus In5 contains another bus a1, which contains two buses left and right. The left and right buses each contain two signals, pressure and temperature.

You can select multiple signals in the signal list by pressing the Ctrl key as you select signals. The following example shows a test case with three signals selected. You can see that the three signals are selected in the signal list, two of them within bus In1 and one root-level individual signal In6. Those three signals are also shown in the signal editing area. Notice that the signal that is selected in the editing pane, pressure, is labeled In1.pressure in the signal diagram, to denote it is a signal within bus In1.

    Note:   If you have a model that contains buses, you can automatically generate a test harness from the model. It will create and configure all of the appropriate parts of the test, including elements, test vectors, and mappings, and create a test case containing all of the Inport blocks as buses and/or signals. For more information, see Test Harness Generation.

You can perform some actions by right-clicking buses and signals in the signal tree. The context menu includes the following commands:

  • Cut

  • Copy

  • Paste

  • Add Signal

  • Add Bus

  • Rename

  • Delete

  • Copy Signal Values to the Same Signal in All Test Cases

In the Test Case view, each level of the bus hierarchy is displayed via icons, as shown here.

The section at the top of the Test Case view shows all of the signals and buses that are included in the test case, in the order they appear in the signal tree. After that, each bus is shown as a group with the signals it contains. The groups appear in the order they appear in the signal tree. Groups for nested buses are also shown.

Notice in the example that bus In1 is a root-level bus containing two signals and no nested buses. But bus In5 is a root-level bus that contains three individual signals, a, a2, and a3, as well as a nested hierarchy of buses a1, left, and right. Each subgroup is shown in its own section in the Test Case view.

Notice that one of the signals that is selected, temperature, is in a group that is labeled In5.a1.left in the signal diagram. This indicates it is a signal within the bus left, which is within bus a1, which is within bus In5.

To edit a signal from the Test Case view, double-click the signal's icon in the icon area or select the signal icon and right-click Edit Signal. The Edit view appears and that signal will be selected for editing.

Add Buses to a Test Case

You can add a bus to a test case, and then add one or more signals to the bus.

  1. In the Edit view, click the Add Bus button that appears above the signal list in the lower-left pane.

    The bus is added below any existing buses or signals in the list, at the highest level in the hierarchy (the root level). It is called Bus1 by default. You can double-click the bus in the signal list to rename it.

  2. The bus is empty until you add signals to it. With the name of the bus still selected in the signal list, click the Add Signal button.

    Select the type of signal to add from the drop-down button.

  3. Add as many signals to the bus as you need, as described in Add Signals to Test Cases.

  4. To add another bus, click the Add Bus button again. A second bus, called Bus2 by default, is added under the first one, at the same level in the hierarchy if a top-level individual signal was selected. If a bus or a signal within a bus is selected when you click Add Bus, the new bus is added under the first bus in a nested hierarchy.

    For example, in the following diagram, In10 is selected when Add Bus is clicked. As a result, Bus1 is added at the end of the bus and signal list. With In10 still selected, if the button is clicked again, Bus2 is added under Bus1 at the same root level.

    With Bus1 selected, clicking Add Signal results in Signal1 being added to that bus. With Bus2 selected, Add Signal results in a Signal1 being added to that bus. Then with Bus1 selected, if you click Add Bus again, the new bus is added under the signal(s) of the first bus as a nested bus, as shown here.

Signal Types

Each signal is defined by several parameters. Using these parameters, the signal generates time-based data. The following rules apply to all the signals:

  • All signal parameters are readable, writable scalar doubles, unless otherwise noted.

  • All time-related parameters are defined in seconds.

  • All parameters have constraints that must always be true, and are enforced when the value is set. For example, Duration must always be positive.

The following tables describe the built-in signal types the tool uses.

Constant

ParameterDefinitionDefault ValueConstraints
Segment DurationThe length of the signal in seconds.10> 0
ValueThe constant value of the signal the entire Duration.1none

Configuration constraint: none.

Step

ParameterDefinitionDefault ValueConstraints
Segment DurationThe length of the signal in seconds.10> 0
Initial ValueThe value of the signal before Offset.0none
Final ValueThe value of the signal after Offset.1none
OffsetThe time in seconds when the signal switches from Initial Value to Final Value.5> 0

Configuration constraint: Duration > Offset.

Ramp

ParameterDefinitionDefault ValueConstraints
Segment DurationThe length of the signal in seconds.10> 0
Initial ValueThe starting value of the signal.0none
Final ValueThe ending value of the signal.1none
OffsetThe time in seconds when the signal begins to transition from Initial Value to Final Value.5=> 0
SlopeThe rate of change of the signal over time..2read-only

Configuration constraint: Initial Value ≠ Final Value.

Pulse

ParameterDefinitionDefault ValueConstraints
Segment DurationThe length of the signal in seconds.10> 0
Initial ValueThe value of the signal before Offset and after Offset + Pulse Width.0none
Final ValueThe value of the pulse after Offset and before Offset + Pulse Width.1none
OffsetThe time in seconds when the signal transitions from Initial Value to Final Value.4> 0
Pulse WidthThe amount of time in seconds after Offset when the signal has the value Final Value. The signal returns to Initial Value afterward for the rest of the signal.2> 0

Configuration constraint: Duration > Offset + Pulse Width.

Configuration constraint: Initial Value ≠ Final Value.

Square

ParameterDefinitionDefault ValueConstraints
Segment DurationThe length of the signal in seconds.10> 0
Initial ValueThe amount the square wave is offset vertically.0none
AmplitudeThe value of the signal while in the high state.1> 0
Duty CycleThe percentage of time the square wave has Amplitude as opposed to – Amplitude..50 < dc <1
Phase ShiftThe value in degrees the signal is horizontally shifted into its period.0none
Period LengthThe length in time for a full repetition of the wave.5> 0

Configuration constraint: none.

Sine

ParameterDefinitionDefault ValueConstraints
Segment DurationThe length of the signal in seconds.10> 0
Initial ValueThe amount the wave is offset vertically.0none
AmplitudeThe amplitude of the sine wave.1> 0
Phase ShiftThe horizontal shift of the period in degrees.0none
Period LengthThe length in seconds of a period.5> 0
Sample RateThe amount in seconds between each sampled point..1> 0

Configuration constraint: none.

Custom

ParameterDefinitionDefault ValueConstraints
TimeUser-defined time vector.[0 2 4 6 8 10]1xN increasing double
DataUser-defined value vector.[2 0 3 2 3 1]1xN double

Configuration constraint: Time and Values must have the same length and dimension.

When specified, Time or Values may be 1xN or Nx1. If specified as Nx1, it will automatically be converted to a 1xN.

Was this topic helpful?