Advanced Testing Techniques

In this guide, we will cover advanced testing techniques.

Overwriting a DUT’s Pre-Stage or Post-Stage

Some tests might require custom setup or teardown stages that differ from those defined in the Device Under Test (DUT). In such cases, you can directly specify these stages within the test file, effectively overriding the default DUT configuration.

To overwrite a DUT’s pre-stage or post-stage, include the desired commands within the pre-stage or post-stage sections of your test configuration. Here is an example:

# Custom Test Configuration
name: Custom Test
description: This test includes custom pre-stage and post-stage commands.

defaults:
  transport: &transport
    proto: ssh
    options:
      host: "[[attributes.Host]]"
      user: root
      password: root

pre-stage:
  - cmd: dutctl
    name: Shutdown the DUT.
    parameters:
      host: "[[attributes.Flasher]]"
      command: power
      args: ["off"]

  - cmd: dutctl
    name: Flash the firmware binary.
    parameters:
      host: "[[attributes.Flasher]]"
      command: flash
      args: [write, "[[defaults.Binary]]"]

  - cmd: dutctl
    name: Turn the DUT on
    parameters:
      host: "[[attributes.Flasher]]"
      command: power
      args: ["hardreset"]
    options:
      timeout: 2m

stages:
  - name: Main Test Stage
    steps:
      - cmd: ping
        name: Wait for SSH service
        options:
          timeout: 2m
        parameters:
          host: "[[attributes.Host]]"

      - cmd: cmd
        name: Run main test command
        transport: *transport
        parameters:
          executable: echo
          args: ["Hello World!"]

post-stage:
  - cmd: dutctl
    name: Clean up. Shutdown the DUT.
    parameters:
      host: "[[attributes.Flasher]]"
      command: power
      args: ["off"]