0% found this document useful (0 votes)
1K views27 pages

SN-HND-1-047 CANoe Test Feature Set Tutorial

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views27 pages

SN-HND-1-047 CANoe Test Feature Set Tutorial

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

CANoe Test Feature Set Tutorial

2020-10-12
Support Note SN-HND-1-047

Author(s) GC, Shyam Sundhar


Restrictions Public Document

Table of Contents
1 About this tutorial.................................................................................................................................... 2
2 The setup ............................................................................................................................................... 3
2.1 CAN database ..................................................................................................................... 3
2.1.1 Create new file ........................................................................................................... 3
2.1.2 Create ECU nodes ..................................................................................................... 3
2.1.3 Create messages ....................................................................................................... 3
2.1.4 Create signals ............................................................................................................ 4
2.1.5 Associate the database .............................................................................................. 5
2.2 Setting up CANoe ................................................................................................................ 5
2.2.1 Add nodes to the network ........................................................................................... 5
2.2.2 Create simulated doors ECU ...................................................................................... 5
2.2.3 Create system variables ............................................................................................. 7
2.2.4 Add remaing bus simulation ....................................................................................... 7
2.3 User test panel ..................................................................................................................... 9
2.3.1 Create new panel ....................................................................................................... 9
2.3.2 Add controls ............................................................................................................... 9
2.4 Verify the configuration....................................................................................................... 10
2.4.1 Check the simulation ................................................................................................ 10
2.4.2 Check the functionality ............................................................................................. 11
3 Testing with CANoe’s Test Feature Set ................................................................................................ 12
3.1 Test Units and Test Modules .............................................................................................. 12
3.2 Testing in CANoe ............................................................................................................... 12
3.2.1 Configuration............................................................................................................ 12
3.2.2 Creating the Test Module ......................................................................................... 12
3.2.3 Executing the tests ................................................................................................... 17
3.3 Testing in vTESTstudio ...................................................................................................... 17
3.3.1 Configuration............................................................................................................ 17
3.3.2 Using CAPL ............................................................................................................. 18
3.3.3 Using C# .................................................................................................................. 18
3.3.4 Using Test Table ...................................................................................................... 19
3.3.5 Using Test Sequence Diagram ................................................................................. 21
3.3.6 Executing the tests ................................................................................................... 23
4 Appendix .............................................................................................................................................. 25
4.1 Network setup .................................................................................................................... 25
4.2 Doors ECU design ............................................................................................................. 25
4.2.1 Features................................................................................................................... 25
4.2.2 Functionality ............................................................................................................. 25
4.2.3 CAN requirements.................................................................................................... 25
4.3 Test design ........................................................................................................................ 26
5 Contacts............................................................................................................................................... 27
CANoe Test Feature Set Tutorial

1 About this tutorial

This tutorial will focus on demonstrating three implementations:


1) Creating a simulated ECU with a single CAN network.
2) Simulating the remaining bus which is required for the simulated ECU.
3) Testing this simulated ECU using CANoe/vTESTstudio as a test authoring tool.

In practice, creating a simulated ECU is not required as the testing will be performed on a real ECU.

We will begin by developing a CAN database to represent the data on a CAN network. This database will
contain three ECUs: Engine, Console and Doors ECUs. The Doors ECU will be the System Under Test (SUT)
and so, we will be simulating this ECU. The messages from the Engine and Console ECUs will be simulated
as a part of the remaining bus simulation. A panel will also be created to manually check the functionality of
the Doors ECU.

Once the simulated network is implemented, we will then use CANoe/vTESTstudio to define a few test cases
in CAPL, C#, Test Table and Test Sequence Diagram to test the functionality of the Doors ECU.

This tutorial is accompanied by a ZIP file SN-HND-1-047_CANoe_Test_Feature_Set_Tutorial.zip. This contains


the implemented solution of this tutorial. This may be used for reference while using this tutorial.

Copyright © 2020 – Vector Informatik GmbH 2


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

2 The setup
Before opening CANoe, create a new directory called “testTFS” to contain all the files pertaining to this
tutorial. This folder will have additional folders for better understanding and organized access of the files
created by CANoe. Create the following sub-folders:

1) CANoe Config
2) DBC
3) ECU Simulation
4) Panels
5) Test Files
6) Test Reports
7) TestUnit Build Output
8) vTESTstudio Project

Open CANoe application, go to File | New and select “CAN 500kBaud 1ch”. Go to File | Save As. Name the
file “testTFS.cfg” and select the sub-folder “CANoe Config”. Then, click [Save].

2.1 CAN database

A network database is not required, but it is always helpful to have one. In most test applications, a network
database will save a lot of time and effort in implementing the test cases. If one is not available, creating a
database is a good first step.

2.1.1 Create new file

1) In CANoe, click the “Tools” ribbon and select CANdb++ Editor to launch the integrated CAN
database editor.
2) In the CANdb++ Editor, go to File | Create Database. A prompt appears to select a
template. Select the template named "EmptyTemplate.dbc".
3) Name the empty DBC file "testTFS.dbc" and save it into the “DBC” sub-folder.

2.1.2 Create ECU nodes

We will now create three network nodes, “Engine”, “Console” and “Doors”.
1) Select “Network Nodes” from the tree view on the left pane of the Overall View window, right-click on
it, and select New. Enter "Doors" in the Name textbox and then click [OK].
2) Repeat step 1 twice, to create two nodes and name them "Engine" and “Console”.

2.1.3 Create messages

We will now create five messages for our simple test application.
1) Select "Messages" in the tree view on the left pane of the Overview window, right-click on it, and
select New.
2) Setup the messages as follows:
o Name = EngineStatus
• Set the DLC (Data LengthCode) to “2”, for 2 bytes of data.
• Select the Transmitters tab and click [Add]. Select “Engine” and click [OK].
o Name = LockingRq
• Set the DLC to “1”.
• Set “Console” to be the transmitter of the message.
o Name = LockingState
• Set the DLC to “1”.
• Set “Doors” to be the transmitter of the message.
o Name = WindowRq
• Set the DLC to “1”.
• Set “Console” to be the transmitter of the message.
o Name = WindowState
• Set the DLC to “1”.

Copyright © 2020 – Vector Informatik GmbH 3


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

• Set “Doors” to be the transmitter of the message.

2.1.4 Create signals

We will now create six signals to represent data within the messages we have just created as follows:
1) Select “Signals” in the tree view on the left pane of the Overview window, right-click on it and select
New.
2) Setup the signal as follows:
o Name = IgnitionStatus
• Enter “1” for Length [Bit].
• Select “Unsigned” for the Value Type.
• Set Minimum to “0” and Maximum to “1”.
• Switch to the Messages tab. Add the message, “EngineStatus” and click [OK].
o Name = LockRequest
• Enter “1” for Length [Bit].
• Select “Unsigned” for the Value Type.
• Set Minimum to “0” and Maximum to “1”.
• Switch to the Messages tab. Add the message, “LockingRq” and click [OK].
o Name = LockState
• Enter “1” for Length [Bit].
• Select “Unsigned” for the Value Type.
• Set Minimum to “0” and Maximum to “1”.
• Switch to the Messages tab. Add the message, “LockingState” and click [OK].
o Name = Velocity
• Enter “8” for Length [Bit].
• Select “Unsigned” for the Value Type.
• Set Minimum to “0” and Maximum to “200”.
• Switch to the Messages tab. Add the message, “EngineStatus” and click [OK].
o Name = WindowPosition
• Enter “4” for Length [Bit].
• Select “Unsigned” for the Value Type.
• Set Minimum to “0” and Maximum to “15”.
• Switch to the Messages tab. Add the message, “WindowState” and click [OK].
o Name = WindowRequest
• Enter “2” for Length [Bit].
• Select “Unsigned” for the Value Type.
• Set Minimum to “0” and Maximum to “2”.
• Switch to the Messages tab. Add the message, “WindowRq” and click [OK].

2.1.4.1 Create value tables (optional but recommended)

Value tables can be made for each signal to represent symbolically, the different value states. We will create a
value table for five of our signals.
1) Select View | Value Tables.
2) Right-click anywhere on the empty page and select New to create a value table.
3) Setup the value tables as follows:
o Name = VtSig_IgnitStatus
• In the Value Descriptions tab, click the [Add] button twice.
• Replace the description for “0x0” to “Engine Off”
• Replace the description for “0x1” to “Engine On”
o Name = VtSig_LockRequest
• In the Value Descriptions tab, click the [Add] button twice.
• Replace the description for “0x0” to “Request to Lock”
• Replace the description for “0x1” to “Request to Unlock”
o Name = VtSig_LockState
• In the Value Descriptions tab, click the [Add] button twice.

Copyright © 2020 – Vector Informatik GmbH 4


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

• Replace the description for “0x0” to “Locked”


• Replace the description for “0x1” to “Unlocked”
o Name = VtSig_WindowPosition
• In the Value Descriptions tab, click the [Add] button twice.
• Replace the description for “0x0” to “Rolled Up”
• Replace the description for “0xF” to “Rolled Down”
o Name = VtSig_WindowRequest
• In the Value Descriptions tab, click the [Add] button thrice.
• Replace the description for “0x0” to “Nothing”
• Replace the description for “0x1” to “Roll Window Up”
• Replace the description for “0x2” to “Roll Window Down”
4) Go back to the Overview window.
5) Double-click on “IgnitionStatus" under Signals. In the window that appears, select “VtSig_IgnitStatus”
in the drop-down box for Value Table. Click [OK].
6) Double-click on “LockRequest" under Signals. In the window that appears, select
“VtSig_LockRequest” in the drop-down box for Value Table. Click [OK].
7) Double-click on “LockState" under Signals. In the window that appears, select “VtSig_LockState” in
the drop-down box for Value Table. Click [OK].
8) Double-click on “WindowPosition" under Signals. In the window that appears, select
“VtSig_WindowPosition” in the drop-down box for Value Table. Click [OK].
9) Double-click on “WindowRequest" under Signals. In the window that appears, select
“VtSig_WindowRequest” in the drop-down box for Value Table. Click [OK].

2.1.5 Associate the database

1) In CANoe select the “Simulation” ribbon and click on Simulation Setup to make sure the Simulation
Setup is displayed.
2) Expand the tree list on the right pane and select Databases. Right-click on it and select Add.
3) Navigate to the DBC sub-folder and select the “testTFS.dbc” database file.

2.2 Setting up CANoe

The CANoe environment needs to be setup so that all the components can interact with each other. The
simulated ECU and the remaining bus simulation must be created using CAPL. The system variables are like
global variables. In this tutorial, we will use the System Variables to control the Engine and Console ECU
simulation from other components like the Panel and Test Units.

2.2.1 Add nodes to the network

1) Go to CANoe and open the Simulation Setup.


2) In the left pane of the window, right-click on the blue/red parallel lines and select Insert Network
Node. A new node will appear on the network with the default name “ECU1”.
3) Right-click on this new node and select Configuration.
4) In the Title text box, enter the name of the node as “Doors”.
5) Add two more nodes “Engine” and “Console” in the same manner.

2.2.2 Create simulated doors ECU

Next, we will use the CAPL programming language of CANoe to define the behavior of our simulated Doors
ECU. A CAPL program is usually developed using the CAPL Browser. The CAPL Browser can be accessed
from the “Tools” ribbon.
We will now begin programming the Doors ECU’s functionality based on the features specified in the
Appendix.
1) In the Simulation Setup of CANoe click on the pencil icon located in the lower-left corner of the
“Doors” network node.
2) An Open dialog will appear asking for the CAPL program to be given a name. Type in “doors.can”
and navigate to the “ECU Simulation” subfolder. Then, click on Open.
3) In the variables section, enter the following code:

Copyright © 2020 – Vector Informatik GmbH 5


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

variables
{
byte WindowState = 0;
byte IgnitionState;

message LockingState LockingStat;


message WindowState WindowStat;
}
4) In the tree view of the left pane of CAPL browser, right-click on “CAN” and select the option “New
Event Handler” | “on message”. An empty procedure for a CAN message appears in code area.
5) Right-click on the highlighted NewMessage and select the option “Insert Database Symbol” |
“Message or Frame”.
6) Select the CAN frame “EngineStatus” from the tree view under Frames.
7) Enter the following code:
on message EngineStatus
{
// Storing Ignition State
if(this.IgnitionStatus) IgnitionState = 1; // Ignition is On
else IgnitionState = 0; // Ignition if Off

// Locking based on velocity


if(IgnitionState == 1 && this.Velocity > 15 &&
LockingStat.LockState == 1)
{
LockingStat.LockState = 0;
output(LockingStat);
}
}
8) Repeat steps 4-5. Then select the CAN frame “LockingRq”.
9) Enter the following code:
on message LockingRq
{
if(this.LockRequest) LockingStat.LockState = 1; // Set State to
"Unlock"
else LockingStat.LockState = 0; // Set State to "Lock"
output(LockingStat);
}
10) Repeat steps 4-5. Then select the CAN frame “WindowRq”.
11) Enter the following code:
on message WindowRq
{
if(IgnitionState)
{
if(this.WindowRequest == 1) //Roll Up window
if(WindowState > 0) WindowState--;
if(this.WindowRequest == 2) //Roll Down window
if(WindowState < 15) WindowState++;
}
WindowStat.WindowPosition = WindowState;
output(WindowStat);
}
12) In the “Home” ribbon, click on “Compile” or type F9. If a compile error is shown at the bottom pane of
CAPL Browser, then double-click on the listed error to get close to the source code line where the
problem is. Fix the error and re-compile until all problems are fixed. If the source code entered has
no problem, the last line at the bottom pane of the CAPL Browser will read “Compilation succeeded
… ”.
13) Compiling will automatically save the file. Now, close the CAPL Browser.

Copyright © 2020 – Vector Informatik GmbH 6


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

2.2.3 Create system variables

1) In CANoe, select the Environment ribbon and click on the “System Variables”. The System Variables
Configuration window will open.
2) In the empty left pane, right-click and select New.
3) Enter the following details for creating a System Variable
o Variable 1
• Namespace : “testNS”
• Name : “IgnitionStart”
• Initial Value : 0
• Minimum : 0
• Maximum : 1
• Value Table : Select “Custom”. Expand the Value Table tree, click the Value Table Items
row to reveal the “Edit Value Table” icon and click it. Now enter the following:
❖ 0 : Ign_OFF
❖ 1 : Ign_ON
4) We will now create 4 more System Variables by right-clicking on the “testNS” row and selecting New.
o Variable 2
• Name : “LockRq”
• Initial Value : 0
• Minimum : 0
• Maximum : 1
• Value Table Items
❖ 0 : RqToLock
❖ 1 : RqToUnlock
o Variable 3
• Name : “Velocity”
• Initial Value : 0
• Minimum : 0
• Maximum : 200
• Unit : kmph
• Value Table : Not required
o Variable 4
• Name : “WindowRequest”
• Initial Value : 0
• Minimum : 0
• Maximum : 2
• Value Table Items
❖ 0 : No_Request
❖ 1 : Roll_Up
❖ 2 : Roll_Down
o Variable 5
• Name : “WindowState”
• Initial Value : 0
• Minimum : 0
• Maximum : 15
• Value Table : Not required
5) Click on [OK].

2.2.4 Add remaing bus simulation

Next, we will again use the CAPL programming language to define the behavior of the remaining bus. The
following program is written based on the expectations of the Doors as specified in the Appendix.
1) In the Simulation Setup of CANoe click on the pencil icon located in the lower-left corner of the
“Engine” network node.
2) An Open dialog will appear asking for the CAPL program to be given a name. Type in “engine.can”
and navigate to the “ECU Simulation” subfolder. Then, click on Open.
Copyright © 2020 – Vector Informatik GmbH 7
Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

3) In the variables section, enter the following:


variables
{
//The following three messages are defined for transmission
message EngineStatus EngineStat;
message LockingRq LkCtrlRq;
message WindowRq WindowCtrl;
//The following timer is for simulating the cyclic message
transmission
msTimer msTimer_EngineStatus;
}
4) In the tree view of the left pane, right-click on System and select the option “New Event Handler | on
start”. Enter the following code:
on start
{
setTimerCyclic(msTimer_EngineStatus,100);
}
5) In the tree view of the left pane, right-click on System and select the option “New Event Handler | on
timer”. Replace the highlighted “NewTimer” with “msTimer_EngineStatus”. Enter the following code:
on timer msTimer_EngineStatus
{
EngineStat.Velocity = @sysvar::testNS::Velocity;
EngineStat.IgnitionStatus = @sysvar::testNS::IgnitionStart;
output(EngineStat);
}
6) In the Simulation Setup of CANoe click on the pencil icon located in the lower-left corner of the
“Console” network node.
7) An Open dialog will appear asking for the CAPL program to be given a name. Type in “console.can”
and navigate to the “ECU Simulation” subfolder. Then, click on Open.
8) In the variables section, enter the following:
variables
{
message LockingRq LkCtrlRq;
message WindowRq WindowCtrl;
}
9) In the tree view of the left pane, right-click on Value Objects and select the option “New Event
Handler | on sysvar_update”. In the Symbols window, click on the “Variables” icon and navigate to
LockRq variable. Now drag and drop the variable on the highlighted “NewSysVar”. Enter the
following code:
on sysvar_update testNS::LockRq
{
if(@sysvar::testNS::LockRq) LkCtrlRq.LockRequest = 1; // Request
Unlock Doors
else LkCtrlRq.LockRequest = 0; // Request Lock Doors
output(LkCtrlRq); // Outputs message onto the bus
}
10) Perform the above step for another variable “WindowRequest” and enter the following code:
on sysvar_update sysvar::testNS::WindowRequest
{
WindowCtrl.WindowRequest = @sysvar::testNS::WindowRequest;
output(WindowCtrl); // Outputs message onto the bus
}
11) In the tree view of the left pane, right-click on CAN and select “New Event Handler | on message”.
Right-click on the highlighted NewMessage and select the option “Insert Database Symbol” |
“Message or Frame”.
12) Select the CAN frame “WindowState” from the tree view under Frames. Enter the following code:

Copyright © 2020 – Vector Informatik GmbH 8


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

on message WindowState
{
@sysvar::testNS::WindowState = this.WindowPosition;
}
13) New click “Compile” or type F9. If there are any errors, rectify them and click Compile again. If the
source code has no errors, the message “Compilation succeeded…“ will be displayed.

2.3 User test panel

A Graphic panel can be created using the “Panel Designer”. This tool can be opened from the “Tools” ribbon
from CANoe. It is recommended to open the tool from CANoe so that the associated database and system
variables are referenced.

2.3.1 Create new panel

1) In CANoe, go to the “Home” ribbon and click on “Panel | New Panel“. The Panel Designer tool will be
opened.
2) Select File | Save. Give the name of the file as “testPanel.xvp” and the location as the “Panels”
subfolder. Click [Save].

2.3.2 Add controls

In this tutorial we will use 2 switches, 2 push buttons and 1 trackbar for controlling the variables. We will also
use 2 indicators and 1 LCD control for display of outputs.
The following steps show how to add switches:
1) On the right side of the Panel Designer, there should be a Toolbox window. If its not visible, go to the
Home ribbon, and select Views Tool Box.
2) Scroll down the list of Vector Standard Controls and click on “Switch/Indicator” and drag it onto the
platform in the center of Panel Designer. A box with a dashed border and a black color switch should
then appear.
3) Open the “Properties” window using the Views option in the Home ribbon.
4) Under the Symbol section, set the symbol filter to Variable. Next, click on Symbol, and then click on
the button to the right of the white box.
5) A window should appear with the list of Symbols, expand the System variable list, and select
“IgnitionStart”. Afterwards, click [OK]. (Alternatively, the system variable can be assigned by dragging
it from the Symbol Explorer on the left pane to the switch box.)
6) Under the Toolbox section, scroll down the list, drag and drop “Static Text” next to the switch on the
gray platform. A box with the words “Description” should appear.
7) In the Properties box, replace the text box property “Text”, from “Description” to “Ignition Start”.
8) Repeat steps 2-5 for the following system variables:
o “LockRq”
o “WindowState” with state count of 17.
9) Repeat steps 2-5 again for the CAN signal “LockState”. For this, set the symbol fiter to Signal and
select the signal “LockState” from the Symbol Selection window. Also, set the Display Only property
to True.
10) (Optional) Switch images may be replaced with user created graphics.
o For “LockState” and “WindowState”, the lock and window images from CANoe’s Central
Locking State Demo were used. (Images used: “LockUnlock.bmp” and “WindowsLeft.bmp”.
Located in the file directory: “C:\ Users\Public\Documents\Vector\CANoe\<Sample
Configurations>\CAN\TestFeatureSet\CentralLockingSystem\CANoe_Configuration\Panels\Bi
tmaps\”).
o If the image is not displayed properly, right click on the control and select Fit Image Size.

The following steps show how to add Push Buttons for window control:
1) From the Toolbox, drag and drop the “Button” control.
2) In the Properties window, change the Text from “Button” to “Window Up”.
3) Under the Symbol section, set the Symbol Filter to Variable. Now select the “WindowRequest”
system variable in the Symbol option.
Copyright © 2020 – Vector Informatik GmbH 9
Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

4) Under Switch Values option, select Roll_Up for Pressed and No_Request for Released.
5) From the Toolbox, drag and drop another “Button” control.
6) In the Properties window, change the Text from “Button” to “Window Down”.
7) Under the Symbol section, set the symbol filter to Variable. Now select the “WindowRequest” system
variable in the Symbol option.
8) Under Switch Values option, select Roll_Down for Pressed and No_Request for Released.

The following steps show how to add controls for changing velocity:
1) From the Toolbox, drag and drop the “Trackbar” control.
2) Under the Symbol section, set the Symbol Filter to Variable. Now select the “Velocity” system
variable in the Symbol option.
3) From the Toolbox, drag and drop the “LCD Control” control.
4) Under the Symbol section, set the Symbol Filter to Variable. Now select the “Velocity” system
variable in the Symbol option.

Save the panel using the option File | Save. You may add additional tools like Group Box to make the panel
visually better. Figure 1 shows the Panel after all the controls are added.

Figure 1

2.4 Verify the configuration

2.4.1 Check the simulation


Start the measurement by clicking the yellow lightning icon at the top left. The simulation of the cyclic frame
“EngineStatus” should be visible in the Trace Window as shown in Figure 2.

Copyright © 2020 – Vector Informatik GmbH 10


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

Figure 2

2.4.2 Check the functionality


Open the “testPanel” and keep the window beside the Trace Window to notice the changes when clicking on
the controls in the panel. Check if the following changes occur when changing the controls:
• Turn on (right-click) and turn off (left-click) the Ignition switch to see the first byte of the “EngineStatus”
frame change between 00 and 01.
• Move the Track bar control and notice the change in byte 2 of the “EngineStatus” frame. Also, the LCD
display should show the current velocity.
• Unlock (right-click) and Lock (left-click) the Locking switch to see additional frames being sent in the
bus (LockingRq and LockingState). When unlocking both the frames will have the value 01 and when
locking it is 00. Also the current lock state is shown in the image next to the switch.
• The window is by default in the close state when starting a measurement. You can click the Window
Down button after turning ON the ignition to notice changes in the window graphic in the panel. Also,
there will be additional CAN frames being sent. When pressing the Window Up/Down button, a
WindowRq frame is sent with value 01 (Up) or 02 (Down) or 00 (Idle). This frame is followed by a
WindowState frame which shows the current window position (00 is closed and 0F is open completely).
Notice that the window state does not change when Ignition switch is OFF.
• Keep the car in Ignition ON and Unlock state, then increase the velocity slowly. Notice that the car locks
automatically when the velocity goes above 14 kmph. This functionality does not work if the Ignition is
OFF.

Figure 3

Copyright © 2020 – Vector Informatik GmbH 11


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

3 Testing with CANoe’s Test Feature Set


3.1 Test Units and Test Modules

There are two types of Test Setups in CANoe. The Test Units Test Setup is used for executing the test
cases created using vTESTstudio and the Test Modules Test Setup is used for executing the test cases
created in CANoe environment.

3.2 Testing in CANoe

CANoe has a built-in testing feature where test cases may be implemented in CAPL language. With CAPL,
test cases will be executed in the order in which they are written in the “MainTest()” test control. Also, it is
important to note that the functionality of a test module CAPL program is not quite the same as that of a
regular CAPL program written to simulate a network node.

3.2.1 Configuration
Let’s begin by setting up the test environment in CANoe.
1) Open the Test Setup by going to the Test ribbon and selecting Test Setup in the Test Modules
group.
2) Right-click in the blank area and select New Test Environment. Enter the name as
“te_FunctionalTests”. Right-click on this environment and click Save. Navigate to the sub-folder “Test
Files” and click [Save].
3) Right-click on this new folder and select Insert CAPL Test Module.
4) Right-click on this new test module and click on Configuration. Enter the name as
“tm_FunctionalTests”. Click on File, navigate to the “Test Files” sub-folder and enter the name as
“CANoeTests.can”. Click [Open] and click [OK].
5) Again right-click on the test module and click Configuration. Under the Test Report tab, add the path
of the sub-folder “Test Reports” in the Test reports path. Click [OK].
6) Again right-click on the test module and click Edit. This will open the CAPL browser.

Note: The CAPL Browser is a tool that comes with the CANoe installation. Typically, this browser is used to
implement a CAPL program to simulate a network node, but it is possible to use it to implement test cases for
a test module.

3.2.2 Creating the Test Module


The CAPL view for a test module is different than the CAPL view for a network node. There are three new
event types, “Test Functions”, “Test Cases” and “Test Control”. The “Test Control” event drives which and
when each test case should be executed. The test cases are defined in the “Test Cases” event type. We will
need to create one function for setting the details of the test module, 2 testfunctions for Pre and Post
conditions and 3 test cases as per the test design mentioned in the Appendix.

3.2.2.1 Supporting functions

1) Variables – The variables section will be present by default when a new CAPL file is created. Enter
the following code in that section.
variables
{
const dword kWAIT_TIMEOUT = 500; // 500msecs
int WaitResult;
}
2) Main Control – Right-click on “Test Control” in the left pane and select New “MainTest”. Type the
following code for MainTest().
void MainTest()
{
cf_testPreparation();
ctc_WindowDownUp();
ctc_RequestLock();
ctc_AutoLock();
}

Copyright © 2020 – Vector Informatik GmbH 12


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

3) Test Preparation – We will create a function which will set the description of the test module and
engineer information. Right-click on Functions in the left pane and select New Function. Replace the
highlighted part with “cf_testPreparation”. Type the following code in that function.

void cf_testPreparation()
{
/* Add Description of Test Module */
TestModuleDescription("Sample test cases written in CAPL.");

/* Add Information into Test engineer Information Table */


TestReportAddEngineerInfo("Company", "Vector Informatik Pvt.
Ltd.");
TestReportAddEngineerInfo("Tester name", "Shyam Sundhar");
TestReportAddSetupInfo("CANoe", "Version 13.0");
TestReportAddSetupInfo("vTestStudio", "Version 5.0");
TestReportAddSUTInfo ("SUT", "Doors ECU");
}
4) Pre and Post conditions – We will create two functions which will be used in all the test cases as
preconditions and postconditions. Right-click on Test Function in the left pane and select New Test
Function. Replace the highlighted part with “PreConditions”. Add another test function and name it as
“PostConditions”. Type the following code in the two functions.

testfunction PreConditions()
{
testStep("Pre-cond","Start");
testStep("","Set Ignition to ON");
// Set Ignition to ON
@sysvar::Main::IgnitionStart =
@sysvar::Main::IgnitionStart::Ign_ON;
testWaitForTimeout(500);
testStep("Pre-cond","End");
}

testfunction PostConditions()
{
testStep("Post-cond","Start");
testStep("","Set Ignition to OFF");
// Set Ignition to OFF
@sysvar::Main::IgnitionStart =
@sysvar::Main::IgnitionStart::Ign_OFF;
testWaitForTimeout(500);
testStep("Post-cond","End");
}

3.2.2.2 Test cases


We will create 3 different test cases as specified in the Appendix. Each test case is created by righ-clicking on
Test Cases in the left pane and selecting New Test Case. This will insert a template for a new test case and
the highlighted text must be replaced with the name of the test case.

1) ctc_WindowDownUp – Type the following code after creating the test case.

testcase ctc_WindowDownUp()
{
int LoopVar;
message WindowState WinStat;

TestCaseTitle("Rolling Windows", "Window Down and Up");

PreConditions();

testStep("Test Step 1", "Rolling down window completely");

Copyright © 2020 – Vector Informatik GmbH 13


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

// For loop to roll down the window completely


for(LoopVar = 1; LoopVar < 16; LoopVar++)
{
testStep("Start","Roll Down Window to position %d",LoopVar);
//Set Window Request to Roll Down
@sysvar::Main::WindowRequest =
@sysvar::Main::WindowRequest::Roll_Down;
// Wait for the message “WindowState” to occur
WaitResult = TestWaitForMessage(WindowState, kWAIT_TIMEOUT);
// Determine results of test step
switch(WaitResult)
{
case 0: TestStepFail("Message not received");
break;
case 1:
// Retrieve the message data of “WinStat”
TestGetWaitEventMsgData(WinStat);
// Check if Actual Window position = Calculated Window
position
if(WinStat.WindowPosition == LoopVar)
TestStepPass("","Window is rolled down to position %d",
WinStat.WindowPosition);
else
TestStepFail("","Window is still in position %d",
WinStat.WindowPosition);
break;
default:
TestStepFail("Failed for other reasons");
}
// Make sure to reset Window Down button to original position
@sysvar::Main::WindowRequest =
@sysvar::Main::WindowRequest::No_Request;
}
TestReportAddWindowCapture("Trace", "" , "Window Down");
traceWindowClear("Trace");
testWaitForTimeout(kWAIT_TIMEOUT);

testStep("Test Step 2", "Rolling up window completely");


// For loop to roll up the window completely
for(LoopVar = 14; LoopVar >= 0; LoopVar--)
{
testStep("Start","Roll Up Window to position %d",LoopVar);
//Set Window Request to Roll Up
@sysvar::Main::WindowRequest =
@sysvar::Main::WindowRequest::Roll_Up;
// Wait for the message “WindowState” to occur
WaitResult = TestWaitForMessage(WindowState, kWAIT_TIMEOUT);
// Determine results of test step
switch(WaitResult)
{
case 0: TestStepFail("Message not received");
break;
case 1:
// Retrieve the message data of “WinStat”
TestGetWaitEventMsgData(WinStat);
// Check if Actual Window position = Calculated Window
position
if(WinStat.WindowPosition == LoopVar)
TestStepPass("","Window is rolled up to position %d",
WinStat.WindowPosition);
else

Copyright © 2020 – Vector Informatik GmbH 14


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

TestStepFail("","Window is still in position %d",


WinStat.WindowPosition);
break;
default:
TestStepFail("Failed for other reasons");
}
// Make sure to reset Window Down button to original position
@sysvar::Main::WindowRequest =
@sysvar::Main::WindowRequest::No_Request;
}
TestReportAddWindowCapture("Trace", "" , "Window Up");

PostConditions();
}
2) ctc_RequestLock – Type the following code after creating the test case.

testcase ctc_RequestLock()
{
message LockingState LockingStatus;

TestCaseTitle("Locking Test", "Request to Lock");

PreConditions();

testStep("","Set request to Lock State");


@sysvar::Main::LockRq = @sysvar::Main::LockRq::RqToLock;

TestStep("Unlocking Test", "Set Locking request to RqToUnlock");


@sysvar::Main::LockRq = @sysvar::Main::LockRq::RqToUnlock;

// Wait for the reply message from Doors ECU for 500ms
WaitResult = TestWaitForMessage(LockingState, kWAIT_TIMEOUT);

// Determine results of test step


switch(WaitResult)
{
case 0: TestStepFail("Message not received");
break;
case 1:
// Retrieve the message data of “LockSysState”
TestGetWaitEventMsgData(LockingStatus);
// If Lock state is unlocked, then test passed.
if(LockingStatus.LockState == VtSig_LockState::Unlocked )
TestStepPass("Test Step 1", "Door is Unlocked");
else TestStepFail("Test Step 1", "Still Locked");
break;
}
TestWaitForTimeout(kWAIT_TIMEOUT); // Wait for 500ms

TestStep("Locking Test", "Set Locking request to RqToLock");


@sysvar::Main::LockRq = @sysvar::Main::LockRq::RqToLock;

// Wait for the message “LockingSysState” to occur for 500ms


WaitResult = TestWaitForMessage(LockingState, kWAIT_TIMEOUT);
// Determine results of test step
switch(WaitResult)
{
case 0: TestStepFail("Message not received");
break;
case 1:
// Retrieve the message data of “LockSysState”
TestGetWaitEventMsgData(LockingStatus);

Copyright © 2020 – Vector Informatik GmbH 15


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

// If Lock state is locked, then test passed.


if(LockingStatus.LockState == VtSig_LockState::Locked )
TestStepPass("Test Step 1", "Door is Locked");
else TestStepFail("Test Step 1", "Still Unlocked");
break;
}
TestWaitForTimeout(kWAIT_TIMEOUT); // Wait for 500ms

PostConditions();
}
3) ctc_AutoLock – Type Type the following code after creating the test case.

testcase ctc_AutoLock()
{
message EngineStatus EngState;
message LockingState LockSysState;
byte ind1,ind2;

TestCaseTitle("Locking Test", "Auto Lock");

PreConditions();

testStep("","Set Locking request to RqToUnlock");


@sysvar::Main::LockRq = @sysvar::Main::LockRq::RqToUnlock;

//Check if the door is "Unlocked" before reaching the threshold


testStep("Set speed","15 kmph");
@sysvar::Main::Velocity = 15;

ind1 = testJoinMessageEvent(EngineStatus);
ind2 = testJoinMessageEvent(LockingState);
testWaitForAllJoinedEvents(200);
testGetWaitEventMsgData(ind1, EngState);
testGetWaitEventMsgData(ind2, LockSysState);

if(EngState.Velocity == 15)
{
testWaitForTimeout(50);
if(LockSysState.LockState == VtSig_LockState::Unlocked)
testStepPass("Door is in Unlocked state before reaching the
speed threshold");
else
testStepFail("Door is not in Unlocked state before reaching the
speed threshold");
}

//Check if the door is "Locked" after reaching the threshold


testStep("Set speed","16 kmph");
@sysvar::Main::Velocity = 16;

ind1 = testJoinMessageEvent(EngineStatus);
ind2 = testJoinMessageEvent(LockingState);
testWaitForAllJoinedEvents(200);
testGetWaitEventMsgData(ind1, EngState);
testGetWaitEventMsgData(ind2, LockSysState);

if(EngState.Velocity == 16)
{
testWaitForMessage(LockingState,200);
if(LockSysState.LockState == VtSig_LockState::Locked)
testStepPass("Door is in Locked state after reaching the speed
threshold");

Copyright © 2020 – Vector Informatik GmbH 16


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

else
testStepFail("Door is not in Locked state after reaching the
speed threshold");
}
testStep("","Reset speed back to 0 kmph");
@sysvar::Main::Velocity = 0;

PostConditions();
}

3.2.3 Executing the tests

Compiling the tests


Before we can begin the tests, we must first compile the tests files we have created. In CANoe, in the Test
Setup for Test Modules window, right-click on “Functional Tests” and select Compile. If there are no errors, a
successful compilation message will pop up.

Running the tests


1) Start the simulation in CANoe by clicking the “lightning bolt” icon in the top left corner of the tool. The
network simulation will be started. Cyclic messages will appear in the Trace Window.
2) To start running the test case, double click on the “Functional Tests” module. This will open the test
module window.
3) In the test module window, there will be a red play button at the botton toolbar. Click on this icon to
start the tests.
4) As each test case is being executed, you should see a “clock” icon in the Verdict column. When a test
case finishes running, its verdict is displayed in the verdict column with either a “green check” or a
“red cross”.

Viewing the report


After all test cases have been executed, a test report may be generated in XML/HTML format or Test Report
Viewer format. This option can be selected in the CANoe global options under General > Test Feature Set >
Reporting File Format. The report can be viewed by clicking the Open Test Report icon at the bottom pane
of the test module window. Alternatively, the report can also be opened by double-clicking on the file in the
directory the report was saved.

3.3 Testing with vTESTstudio

To start a new project, open vTESTstudio and select the option File | New Project. Enter the name
“testVTS.vtsoproj” and navigate to the “vTESTstudio Files” subfolder. Click on [Save]. By default, certain
windows will be open after creating a new project. But any window can be open at a later stage by clicking the
“Layout” ribbon and selecting the required window.

There are five different test design editors for implementing test cases in vTESTstudio. The test cases and
functions can either be implemented within one test design editor or be shared over different test design
editors according to the respective capabalities of the respective editor. For example a predefined CAPL test
function can be called from within a test table or a test sequence diagram.

3.3.1 Configuration

In vTESTstudio
We will first set up the environment required for developing test cases. In the Project View, right-click on the
project name “testVTS” and select Project Configuration. In the System Environment tab, click on [Import].
While importing, the CANoe configuration testTFS.cfg should be loaded. This action will import the databases,
system variables and other related files into the vTESTstudio environment.

Select the “Build” tab and enter the path of the subfolder “TestUnit Build Output” in the Output directory text
box. Accept these setting via Apply in the upper left corner of the Project Configuration and save the project
via File | Save Project File.

Copyright © 2020 – Vector Informatik GmbH 17


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

In CANoe
Open the Test Setup by going to the Test ribbon and selecting Test Setup in the Test Units group. Right-
click on the blank area and select Add Test Configuration. Name the configuration as “Functional Tests”. A
new window for this test configuration will be opened.
In the Test Setup, right-click on the “Functional Tests” and select Configuration. Under the Test Report
heading, Test report path, select the sub-folder “Test Reports”. This will ensure that all the reports are
contained in one folder for easier access.

3.3.2 Using CAPL


1) In the Project View, right-click on the project name “testVTS” and select New Test Unit. Change the
name of this test unit to “tu_CAPL”.
2) Right-click on the test unit and select Add | CAPL File. Name the file as CAPL_FuncTests.
3) Copy the contents from the file “…\ref_testTFS\vTESTstudio
Project\ref_tu_CAPL\ref_CAPL_FuncTests.can” to this new CAPL file.
4) This file contains 3 test cases. ctc_WindowDownUp, ctc_RequestLock and ctc_AutoLock. The
complete test case along with preconditions and postconditions are written inside of these three test
cases.
5) It also contains functions for preconditions, postconditions and test preparation.
6) Again right-click on the test unit and select Add | Test Table. Name the file as tt_CAPL_FuncTests.
This test table works as the starting point from which the test cases are called. The Test Table Editor
will be opened in the middle pane.
7) In the middle pane of the editor, click on the drop-down box under Test Tree and select Test Fixture.
Under the Test Fixture, select Fixture Preparation from the drop-down list. Under the Preparation,
select the function cf_TestPreparation.
8) Right click on the new line and select Move Level Up. Select ctc_WindowDownUp in the drop down
list. Then select the remainng two test cases in the new lines. The test tree should look like as shown
in Figure .

Figure x
9) Save this file. Click on Build Test Unit in the Home ribbon to check if there are any errors.

3.3.3 Using C#
1) In the Project View, right-click on the project name “testVTS” and select New Test Unit. Change the
name of this test unit to “tu_CSharp”.
2) Right-click on the test unit and select Add | C# File. Name the file as NET_FuncTests.
3) Copy the contents from the file “…\ref_testTFS\vTESTstudio
Project\ref_tu_CSharp\ref_NET_FuncTests.can” to this new C# file.
4) This file contains 3 test cases. ntc_WindowDownUp, ntc_RequestLock and ntc_AutoLock. The
complete test case along with preconditions and postconditions are written inside of these three test
cases.
5) It also contains functions for preconditions, postconditions and test preparation.

Copyright © 2020 – Vector Informatik GmbH 18


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

6) Again right-click on the test unit and select Add | Test Table. Name the file as tt_NET_FuncTests.
This test table works as the starting point from which the test cases are called. The Test Table Editor
will be opened in the middle pane.
7) In the middle pane of the editor, click on the drop-down box under Test Tree and select Test Fixture.
Under the Test Fixture, select Fixture Preparation from the drop-down list. Under the Preparation,
select the function nf_TestPreparation.
8) Right click on the new line and select Move Level Up. Select ntc_WindowDownUp in the drop down
list. Then select the remainng two test cases in the new lines. The test table should look like as shown
in Figure .

Figure x
9) Save this file. Click on Build Test Unit in the Home ribbon to check if there are any errors.

3.3.4 Using Test Table


The Test Table Editor allows users to easily define test sequences in tabular form without the need for
programming expertise. Special commands are available for stimulating and testing the System Under Test.
The chapter named “Definition of the Execution Tree” in the vTESTstudio help will give a short description of
the execution elements available in the Test Table Editor.
1) In the Project View, right-click on the project name “testVTS” and select New Test Unit. Change the
name of this test unit to “tu_TestTable”.
2) Right-click on the test unit and select Add | Test Table. Name the file as tt_TestTable_FuncTests.
This test table works as the starting point from which the test cases are called. The Test Table Editor
will be opened in the middle pane.
3) Before creating test cases, we need to create three supporting functions. These can be added in the
Functions pane of the editor located in the lower left side. Click on Function Definitions. In the middle
pane, a new line will be available under Function Definitions. Each command can be added by
selecting it from the drop-down list for a new line. Moving levels can be done by right clicking on any
line.
1. tf_TestPreparation
i. Add Function Definition. Enter “tf_TestPreparation” in Caption.
ii. Add CAPL Inline. Enter the following code in the Code field.

TestReportAddEngineerInfo("Company", "Vector Informatik Pvt. Ltd.");


TestReportAddEngineerInfo("Tester name", "First tester");
TestReportAddSetupInfo("CANoe", "Version 13.0");
TestReportAddSetupInfo("vTestStudio", "Version 5.0");
TestReportAddSUTInfo ("SUT", "Doors ECU");

2. tf_Preconditions
i. Move one level up. Add Function Definition. Enter “tf_Preconditions”.
ii. Add Set command. In the “Set” box, select the system variable “IgnitionStart”. System
variables are denoted by a blue/red sine wave. In the value box after the “=” symbol,
select Ign_ON.

Copyright © 2020 – Vector Informatik GmbH 19


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

iii. Add Wait command. Enter 500 in the Time field.


3. tf_PostConditions
i. Move one level up. Add Function Definition. Enter “tf_PostConditions”.
ii. Add Set command. In the “Set” box, select the system variable “IgnitionStart”. In the
value box after the “=” symbol, select Ign_OFF.
iii. Add Wait command. Enter 500 in the Time field.
4) We will now create the test case in a step-by-step manner. Each step involves adding a command in
the middle pane and changing its respective properties in the right pane. Each command can be
added by selecting it from the drop-down list of a new line. Moving levels can be done by right clicking
on any line. Click on “Test Tree” under “Test Execution Tree” in the upper right pane of the editor.
1. Add a Test Fixture.
2. Add a Fixture Preparation.
3. Select the function tf_TestPreparation.
4. Move one level up. Add a Test Case. Enter “ttc_WindowDownUp” in Caption field.
5. Add Preparation.
6. Select the function tf_Preconditions.
7. Move one level up. Add the command For. Enter Loop Variable as “count”, Start Value as 1,
Stop Value as 15 and Increment as 1.
8. Add Set command. Select the system variable “WindowRequest” in Set field and select
“Roll_Down” in value field.
9. Add Await Value Match command. In the Check field, select the CAN signal
“WindowPosition”. A CAN signal will be denoted by a grey sine wave. Enter “count” in the
same row. Enter 100 in Timeout field.
10. Add Set command. Select the system variable “WindowRequest” in Set field and select
“No_Request” in value field.
11. Add Wait command. Enter 100 in Time field.
12. Move one level up. Add the command For. Enter Loop Variable as “count”, Start Value as 14,
Stop Value as 0 and Increment as -1.
13. Add Set command. Select the system variable “WindowRequest” in Set field and select
“Roll_Up” in value field.
14. Add Await Value Match command. In the Check field, select the CAN signal
“WindowPosition”. A CAN signal will be denoted by a grey sine wave. Enter “count” in the
same row. Enter 100 in Timeout field.
15. Add Set command. Select the system variable “WindowRequest” in Set field and select
“No_Request” in value field.
16. Add Wait command. Enter 100 in Time field.
17. Move one level up. Add Completion command.
18. Select the function tf_Postconditions.
19. Move one level up. Add a Test Case. Enter “ttc_RequestLock” in Caption field.
20. Add Preparation.
21. Select the function tf_Preconditions.
22. Move one level up. Add Set command. Select the system variable “LockRq” in Set field and
select “RqToUnlock” in value field.
23. Add Await Value Match command. In the Check field, select the CAN signal “LockState”.
Select “Unlocked” in the same row. Enter 100 in Timeout field.
24. Add Set command. Select the system variable “LockRq” in Set field and select “RqToLock” in
value field.
25. Add Await Value Match command. In the Check field, select the CAN signal “LockState”.
Select “Locked” in the same row. Enter 100 in Timeout field.
26. Add Completion command.
27. Select the function tf_Postconditions.
28. Move one level up. Add a Test Case. Enter “ttc_AutoLock” in Caption field.
29. Add Preparation.

Copyright © 2020 – Vector Informatik GmbH 20


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

30. Select the function tf_Preconditions.


31. Move one level up. Add Set command. Select the system variable “LockRq” in Set field and
select “RqToUnlock” in value field.
32. Add Set command. Select the system variable “Velocity” in Set field and enter 15 in the same
row.
33. Add Await Value Match command. Select the CAN signal “Velocity” in the Check field. Enter
the value 15 in the same row. Enter 200 in Timeout field.
34. Add Await Value Match command. Select the CAN signal “LockState” in the Check field.
Select “Unlocked” in the same row. Enter 100 in Timeout field.
35. Add Set command. Select the system variable “Velocity” in Set field and enter 16 in the same
row.
36. Add Await Value Match command. Select the CAN signal “Velocity” in the Check field. Enter
the value 16 in the same row. Enter 200 in Timeout field.
37. Add Await Value Match command. Select the CAN signal “LockState” in the Check field.
Select “Locked” in the same row. Enter 100 in Timeout field.
38. Add Set command. Select the system variable “Velocity” in Set field and enter 0 in the same
row.
39. Add Completion command.
40. Select the function tf_Postconditions.

3.3.5 Using Test Sequence Diagram


1) In the Project View, right-click on the project name “testVTS” and select New Test Unit. Change the
name of this test unit to “tu_SeqDiag”.
2) We will now add 3 diagrams for the 3 test cases and 2 diagrams for preconditions and postconditions.
Each diagram will generate multiple test cases unless we configured it not to.
3) Right-click on the test unit and select Add | Test Sequence Diagram. Name the file as
“Preconditions”. Right-click on this file and select Exclude from Execution Tree. Since we will be
using this diagram in other test cases, we won’t need test cases based on this diagram.
4) Perform the step 3 again to create a file “Postconditions”.
5) Add three more Test Sequence Diagrams with the names “dtc_WindowDownUp”, “dtc_RequestLock”
and “dtc_AutoLock”.
6) Double click on the Preconditions file to open it. This opens the Test Diagram Editor. It has all the
Test Tools on the left pane and the middle pane is used to design the test sequence. The following
steps shows how to create the sequence for preconditions.
a. Drag and drop the Start element to the middle pane. This element defines the starting point of
a test diagram.
b. Drag and drop the Finalize element. This element defines the ending point of a test diagram.
c. Select the Transition element and join both the Start and Finalize elements in the middle
pane. The commands for each element is added in the bottom pane. For the Transition
element, add the following commands:
i. Select the Set command. Select the system variable “IgnitionStart” in the Set field
and select the value “Ign_ON”.
ii. Select the Wait command. Enter 500 in the Time field.
7) Double click on the Postconditions file to open it. The following steps shows how to create the
sequence for postconditions.
a. Drag and drop the Start element.
b. Drag and drop the Finalize element.
c. Select the Transition element and join both the Start and Finalize elements in the middle
pane. Add the following commands:
i. Select the Set command. Select the system variable “IgnitionStart” in the Set field
and select the value “Ign_OFF”.
ii. Select the Wait command. Enter 500 in the Time field.
8) Double click on the “dtc_WindowDownUp” file to open it. The following steps shows how to create the
test sequence for this test case.
Copyright © 2020 – Vector Informatik GmbH 21
Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

a. Drag and drop the Start element.


b. Drag and drop the Diagram Link element. This element is a call to another diagram. In the
bottom pane, select “Preconditions” from the drop down list in the Diagram field. Enter
“Preconditions” in the Caption field.
c. Add a Transition element starting from the Start element and ending at Diagram Link
element.
d. Drag and drop the For Loop element. Enter “count” in the Loop Variable field, 1 in Start Value
field, 15 in Stop Value Field and 1 in Increment field.
e. Join the Preconditions and For Loop elements with a Transition element.
f. Add a Check element inside the For Loop element. Enter “No Command” in the Caption field.
g. Add another Check element inside the For Loop element. Add Await Value Match
command. Select the CAN signal “WindowPosition” in the Check field. Enter “count” in the
value field. Enter 100 in Timeout field. Enter “Check Window Position” in the Caption field.
h. Add a Transition element starting from element in f. to element in g. Add a Set command
and select the system variable “WindowRequest” with “Roll_Down” in value field. Enter “Roll
Down Request” in the Caption field.
i. Add another Check element inside the For Loop element. You may re-size the For Loop
element if required. Enter “No Command” in the Caption field.
j. Add a Transition element starting from element in g. to element in i. Add a Set command and
select the system variable “WindowRequest” with “No_Request” in value field. Add a Wait
command and enter 100 in Time field. Enter “No Request” in the Caption field.
k. Elements can be copied in this editor. Now, select the For Loop element and copy it using
Ctrl+C. Paste it using Ctrl+V and place the second For Loop below the first one. The following
changes needs to be made in the second For Loop element:
i. Select the second For Loop element and change the Start Value to 14, Stop Value to
0 and Increment to -1.
ii. Select the first Transition element and change the WindowRequest value from
“Roll_Down” to “Roll_Up”. Also change the Caption to “Roll Up Request”.
l. Add a Transition element starting from the first For Loop element and ending at the second
For Loop element.
m. Drag and drop the Diagram Link element. In the bottom pane, select “Postconditions” from
the drop down list in the Diagram field. Enter “Postconditions” in the Caption field
n. Add a Transition element starting from the second For Loop element and ending at Diagram
Link element.
o. Drag and drop the Finalize element.
p. Add a Transition element starting from the Diagram Link element and ending at the Finalize
element.
9) Double click on the “dtc_RequestLock” file to open it. The following steps show how to create the test
sequence for this test case.
a. Drag and drop the Start element.
b. Drag and drop the Diagram Link element. In the bottom pane, select “Preconditions” from the
drop down list in the Diagram field. Enter “Preconditions” in the Caption field.
c. Add a Transition element starting from the Start element and ending at Diagram Link
element.
d. Add a Check element. Add Await Value Match command and select the CAN signal
“LockState” in the Check field with value “Unlocked”. Enter 100 in the Timeout field. Enter
“Check Unlock” in the Caption field.
e. Add a Transition element from the Diagram Link element to Check element. Add a Set
command and select the system variable “LockRq” in the Set field and “RqToUnlock” in its
value field. Enter “Request to Unlock” in the Caption field.
f. Add a Check element. Add Await Value Match command and select the CAN signal
“LockState” in the Check field with value “Locked”. Enter 100 in the Timeout field. Enter
“Check Lock” in the Caption field.

Copyright © 2020 – Vector Informatik GmbH 22


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

g. Add a Transition element from the element in d. to element in f. Add a Set command and
select the system variable “LockRq” in the Set field and “RqToLock” in its value field. Enter
“Request to Lock” in the Caption field.
h. Drag and drop the Diagram Link element. In the bottom pane, select “Postconditions” from
the drop down list in the Diagram field. Enter “Postconditions” in the Caption field.
i. Add a Transition element starting from the element in f. and ending at Diagram Link element.
j. Drag and drop the Finalize element.
k. Add a Transition element starting from the Diagram Link element and ending at the Finalize
element.
10) Double click on the “dtc_AutoLock” file to open it. The following steps shows how to create the test
sequence for this test case.
a. Drag and drop the Start element.
b. Drag and drop the Diagram Link element. In the bottom pane, select “Preconditions” from the
drop down list in the Diagram field. Enter “Preconditions” in the Caption field.
c. Add a Transition element starting from the Start element and ending at Diagram Link
element.
d. Add a Check element. Add Await Value Match command and select the CAN signal
“Velocity” in the Check field with value 15. Enter 200 in the Timeout field. Add another Await
Value Match command and select the CAN signal “LockState” in the Check field with value
“Unlocked”. Enter 100 in the Timeout field Enter “Check Unlocked” in the Caption field.
e. Add a Transition element from the Diagram Link element to Check element. Add a Set
command and select the system variable “LockRq” in the Set field and “RqToUnlock” in its
value field. Add another Set command and select the system variable “Velocity” in the Set
field with value 15. Enter “Set Velocity at 15 kmph” in the Caption field.
f. Add a Check element. Add Await Value Match command and select the CAN signal
“Velocity” in the Check field with value 16. Enter 200 in the Timeout field. Add another Await
Value Match command and select the CAN signal “LockState” in the Check field with value
“Locked”. Enter 100 in the Timeout field Enter “Check Locked” in the Caption field.
g. Add a Transition element from the element in d. to element in f. Add a Set command and
select the system variable “Velocity” in the Set field with value 16. Enter “Set Velocity at 16
kmph” in the Caption field.
h. Drag and drop the Diagram Link element. In the bottom pane, select “Postconditions” from
the drop down list in the Diagram field. Enter “Postconditions” in the Caption field.
i. Add a Transition element starting from the element in f. and ending at Diagram Link element.
Add a Set command and select the system variable “Velocity” in the Set field with value 0.
Enter “Set Velocity at 0 kmph” in the Caption field.
j. Drag and drop the Finalize element.
k. Add a Transition element starting from the Diagram Link element and ending at the Finalize
element.

3.3.6 Executing the tests

Compiling the tests


In vTESTstudio, in the Home tab, click the Build All Test Units button. This will compile all the test units and
create .vtuexe files in the TestUnit Build Output sub-folder. A “Build succeeded” message will be displayed in
the Output window if there are no errors. Alternatively, each test unit can be individually compiled by selecting
the test unit and clicking on Build Test Unit button.

Running the tests


1) In CANoe, go to the Test Configuration “Functional Tests”.
2) Click the Add Test Unit icon in the top toolbar of the Test Configuration. Navigate to the “TestUnit
Build Output” sub-folder and select all the .vtuexe files which were generated by vTESTstudio. The
test case names will now load in the window.
3) Start the simulation in CANoe by clicking the “lightning bolt” icon in the top left corner of the tool. The
network simulation will be started. Cyclic messages will appear in the Trace Window.

Copyright © 2020 – Vector Informatik GmbH 23


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

4) In the Test Configuration “Functional Tests”, click the orange play icon. This will start running the tests
sequentially. Before starting this, you maybe select the test cases to be run by using the check boxes
before each test.
5) As each test case is being executed, you should see a “clock” icon in the Verdict column. When a test
case finishes running, its verdict is displayed in the verdict column with either a “green check” or a
“red cross”.

Viewing the report


After all test cases have been executed, a test report may be generated in XML/HTML format or Test Report
Viewer format. This option can be selected in the CANoe global options under General > Test Feature Set >
Reporting File Format. The report can be viewed by clicking the Open Test Report icon at the upper right
corner of the Test Configuration. Alternatively, the report can also be opened by double-clicking on the file in
the directory the report was saved.

Copyright © 2020 – Vector Informatik GmbH 24


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

4 Appendix
4.1 Network setup

Figure 1 – Test setup concept

4.2 Doors ECU design

4.2.1 Features
1. Lock or Unlock
2. Window Up or Window Down (16 levels)

4.2.2 Functionality
1. Lock/Unlock based on request from Console ECU.
2. Lock based on car velocity (ignition is ON, velocity > 15 km/h and unlocked state).
3. Raise or lower Window by one level based on a state transition from No_Request to Roll_Up or
Roll_Down (only when ignition is ON).

4.2.3 CAN requirements


Tx CAN frames and signals
1. WindowState (ID - 0x4) – Event Triggered
a. WindowPosition
2. LockingState (ID - 0x2) – Event Triggered
a. LockState

Rx CAN frames and signals


1. EngineStatus (ID - 0x0) – Cyclic 100ms
a. IgnitionStatus
b. Velocity
2. LockingRq (ID - 0x1) – Event Triggered
a. LockRequest
3. WindowRq (ID - 0x3) – Event Triggered
4. WindowRequest

Copyright © 2020 – Vector Informatik GmbH 25


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

4.3 Test design


1. Window down up test
From the intial state (window closed), set WindowRequest to value 2 and check if the window level
has reduced by one. Reset the signal back to 0. Check this for all levels of the window.
Set the signal WindowRequest to value 1 and check if the window level has increased by one. Reset
the signal back to 0. Check this for all levels of the window.
2. Request lock test
Set the value of the signal LockRequest to value 0 and check if door is locked (signal LockState).
Set the value of the signal LockRequest to value 1 and check if door is unlocked (signal LockState).
3. Auto lock test
Set the door to unlock state. Increase speed to 15 km/ph and check if the door is still unlocked. Increase
speed to 16 kmph and check if the door is locked.

Copyright © 2020 – Vector Informatik GmbH 26


Contact Information: www.vector.com or +49-711-80 670-0
CANoe Test Feature Set Tutorial

5 Contacts
For support related questions please address to the support contact for your country
https://www.vector.com/int/en/company/contacts/support-contact/.

Copyright © 2020 – Vector Informatik GmbH 27


Contact Information: www.vector.com or +49-711-80 670-0

You might also like