CIP Test Suite - Console

Table of Contents

logo-large

Tutorial Actifsource Tutorial – CIP Test Suite - Console
Required Time - 30 Minutes
Prerequisites - Actifsource Tutorial – Actifsource Tutorial – [Installing Actifsource]../../..(/tutorials/\10_community/10_install/index.html)
-Actifsource Tutorial – Simple Service
- Actifsource Tutorial – CIP Statemachine - Lamp
Goal - Creating Unit Tests for a CIP Statemachine
Topics covered - Setting up the code options
- Setting up a CIP Test Suite
- Generate the CIP Test Suite
- Generate the CIP Test Suite Documentation
Notation ↪ To do
ⓘ Information
Bold: Terms from actifsource or other technologies and tools
Bold underlined: actifsource Resources
Monospaced: User input
Italics: Important terms in current situation
Disclaimer The authors do not accept any liability arising out of the application or use of any information or equipment described herein. The information contained within this document is by its very nature incomplete. Therefore the authors accept no responsibility for the precise accuracy of the documentation contained herein. It should be used rather as a guide and starting point.
Contact Actifsource AG
Täfernstrasse 37
5405 Baden-Dättwil
Switzerland
www.actifsource.com
Trademark Actifsource is a registered trademark of Actifsource AG in Switzerland, the EU, USA, and China. other names appearing on the site may be trademarks of their respective owners.

Overview

  • Learn how to specify a CIPTestSuite model

    • Specify message events (input)
    • Specify message action expectations (output)
  • Run the unit tests

Part I Setting up the CIP project

  • Make sure to properly setup the lamp project as seen in the previous tutorial

image2 image2

  • Create a new CIP Project using the wizard
  • Select CIP_C_Statemachine to generate a CIP state maschine
  • Select CIP_C_TestSuite_Console to generate a console test suite
  • Select CIP_HTML_TestSuite_Documentation to generate a html documentation
  • Click Next >

image3 image3

  • The necessary build configs are automatically added to your target folder
  • Click Finish

image4 image4

  • Create the Lamp state machine as shown in the previous tutorial

image5 image5

image6 image6

  • Set the timer delay to 3 ticks

image7 image7

  • Create a new Implementation in your CIPSystem
  • Select the LampCluster in your CipMachine
  • Select input and output channels
  • Select Default_C_CodeOptions

image8 image8

  • Install the CDT (C/C++ development tool)
  • Convert your project to a C/C++ Project

image9 image9

  • Convert to C Project
  • Create an Executable
  • Click Finish

image10 image10

  • To automatically compile choose Build on resource save in the project properties

image11 image11

  • Rearrange the CDT Builder to the last position to make sure that the actifsource generator runs before compiling

Part II Setting up a CIP Test Suite

  • Create a new Resource of type CipTestSuite
  • Specify your test cases

image12 image12

  • Create a new Resource of type CipTestSuite
  • Reference you CIP system and the implementation unit which shall be tested

image13 image13

  • Create a new TestCase called LampOnOff
  • Make sure to properly comment all resources via the comment attribute.

image14 image14

  • Define the first test event of type MessageEvent

  • First define the event message which is sent to the CIP machine

  • Let’s switch on the light by pressing the button

    • Select event message Button.Push
    • Define the expected action message Lamp.Bright

image15 image15

  • Define the second test event of type MessageEvent

  • First define the event message which is sent to the CIP machine

  • Let’s activate the switch off delay by pressing the button

    • Select event message Button.Release
  • Since switching off is delayed, we do not expect the light to be switched off

image16 image16

  • Define the third test event of type TickEvent

  • Define the number of ticks to time up the delay

    • 3 ticks in this example
    • Define the expected action message Lamp.Dark
  • The light is expected to be switched off after 3 ticks

Part III Running the CIP Test Suite

  • In the second part we want to generate an executable which can run the previously defined test cases
  • Make sure to install the CDT (C/C++ Development Tool) and mingw or gcc for C language support

image17 image17

  • Your lamp system should have been generated by now
  • Select your executable and run configuration

image18 image18

  • Select the command line options

    • Select regressive to automatically run test cases
    • Select manual to manually stimulate the event

image19 image19

  • Run the Local C/C++ Application

image20 image20

  • The test out can be found in the console
Info

Note that you can directly link back from the console output in the corresponding model by clicking on the blue GUID links

image21 image21

  • Delete the expectation Lamp.Bright in your first test event and run the test again
  • Link back to the model by clicking the GUID link next to the assertion failure
  • Correct your test model

Part IV Generate the CIP Test Suite Documentation

  • Last but not least we want to generate the test suite documentation
  • The documentation can be used for communication and to ensure quality
  • Make sure to define a new test case any time a problem in your state machine hast been corrected

image22 image22

  • The documentation is generated because of the BuildConfig CIP_HTML_TestSuite_Documentation
  • A file Test_CipSystem_TestSuite_Documentation.html is generated in your target folder

image23 image23

  • Use the generated documentation to ensure quality and communicate with your team mates.

image24 image24

  • Click on messages in the test cases to link back to the system information

actifsource-point-large