Framework Components - JanJorgensen/StepBro GitHub Wiki

Overview

There are various components to the StepBro framework:

  • TestFramework.sbs script file
  • Stepbro Station Properties configuration file

TestFramework

The TestFramework.sbs script file is a framework for structured test projects. The main contents are:

  • TestCase procedure
  • TestSuite testlist
  • Action procedure

TestCase

This procedure can be used as the base procedure for all test case procedures in a test project.

The TestCase procedure has the FreeParameters property set, to make it possible to create test case procedures that has parameters, and the procedures does not have to have the same parameters.

Partners

The procedure has several partners defined.

  • Callback partners
    • Setup, which will be called just before the TestCase procedure in formal tests.
    • Cleanup, which will be called just after the TestCase procedure in formal tests.
    • PreTest, which will be called at first in all the TestCase execution partners, to prepare for the execution and check any preconditions.
  • Execution partners
    • TestUntilFail
      The default procedure for this partner is the TestCaseTestUntilFail procedure.
      This partner will first call the PreTest partner, and then call the TestCase procedure itself in a loop infinitely until a failure occurs.
    • TestFormal
      The default procedure for this partner is the TestCaseFormalTest procedure.
      This partner will:
      1. call the PreTest partner
      2. call the Setup partner
      3. call the TestCase procedure
      4. call the Cleanup partner
    • TestFormalUntilFail
      The default procedure for this partner is the TestCaseFormalTestUntilFail procedure.
      This partner will first call the PreTest partner, and then call the Setup partner, the TestCase procedure and the Cleanup partner in a loop infinitely until a failure occurs.

TestSuite

Action

file contains two various models for executing testlists, such as InfiniteTest, FormalTest, and DirectTest.

The InfiniteTest will run a testlist in a loop forever while it passes. This is useful for long-term testing, to test that a program does not fail randomly once every 100 times or after a certain amount of time or similar.

The FormalTest will run a testlist and generate a test report and test summary during the execution of the testlist. This is useful for when you want to create a test report for CI or for when you want to release software.

The DirectTest will run a testlist directly and will not generate anything. This is useful for quick testing where a formal test report is not needed.

Station Properties

The Station Properties file, is a file that contains local configuration, that can be utilized by StepBro to create generic test scripts while interacting with specific devices and using specific machine resources (files and folders).

The idea is to be able to run the same scripts on different computers, each potentially having different setups. Each computer then has a specialized version of a station properties file.

The file generally contains:

  • Device configuration
  • File and folder locations for local resources or targets for files generated by the test execution.

The name and location of the Station Properties file must be set in a system environment variable named STEPBRO_STATION_PROPERTIES. The value of the variable should be the path to your file, including the file, for example: "c:\Users\USERNAME\Documents\StepBro Station Properties.cfg".

Device Configurations

All device configurations should be added to a section named devices in the station properties file. In that section, all devices must be listed. Each device configuration has the following format:

<device name>:
{
    devicetype: <type>,
    aliases: [<device name>, <device name>],
    <device property>: <property value>,
    <device property>: <property value>,
}

The aliases field is optional.

The device property fields are optional and the can be any number of fields configured. These fields will be used in the scripts as default values for the device object properties with the same names as the configured fields.

Configuration Example

devices:
{
    Device01:
    {
        devicetype: CommPort,
        aliases: [FirstDevice, MainDevice],
        portname: "COM4",
        baudrate: 9600
    },
    Device02:
    {
        devicetype: CommPort,
        aliases: [SecondDevice, SecondaryDevice],
        portname: "COM25",
        baudrate: 230400
    }
}

In the example, there is a Device01, which is of the devicetype CommPort (i.e. COM Port), has two aliases that can be used, as well as Device01, in a StepBro script file. It uses the port "COM4", and has a baudrate of 9600.

The portname is different for each device and is different on each computer, so it would need to be checked on a case by case basis. This is why this file is useful, as we would otherwise have to manually change a part of the StepBro script file if we want to use the device that is connected to each computer.

Then we have a Device02 that contains the same information, with different aliases and a different portname.

Using device configuration in script files

When setting up a device in a script, the reserved field Device, can be used to refer to a device configuration in the station properties file.

Example

public SerialPort portDevice01 = SerialPort()
{
    Device = Device01,
    StopBits = One
}

public HarnessConnection device01Connection = SerialTestConnection()
{ 
    Stream = portDevice01, 
    CommandResponseTimeout = 2s
}

In the definition for portDevice01, we say Device = Device01, this tells StepBro that we want to use the device called "Device01" from the Station Properties file.

StepBro uses that information to use the configured properties from the station properties file as default values for the object properties with matching names.

⚠️ **GitHub.com Fallback** ⚠️