Skip to main content

Automated Fixturing

During this tutorial you have:

  • manually invoked a GitHub workflow to publish pre-canned results
  • implemented and executed new test specs from scratch
  • learned how to generate and manage GitHub issues with failing tests
  • formally defined a test session consisting of a set of specs for testing a build
  • leveraged Exploratory Testing for non-scripted verification
  • used variables and includes when implementing test specs

This section of the tutorial will be demonstrating the power of automation, integrated into a manual test, using a Spec Fixture based on a Github Action.

info

This example highlights the built-in automated fixturing for "manual" tests.

Files Used

The following files and their content is used in this section of the tutorial

  • Spec file - use.setup.fixture.md
  • GitHub workflow yaml file - testspace.yml
  • JavaScript file - handler.js

The repo file structure:

root
└─ .github/workflows
└─ testspace.yml
└─ handler.js
└─ specs
└─ use.setup.fixture.md

Spec

To enable manual automation a front matter block is used at the beginning of the spec. The header section below defines a before fixture, which requires successful execution before test cases can be manually executed.

A fixture is used to execute serverless automation, which sets the state of the spec before manual test case execution begins.

The specs/use.setup.fixture.md file contains the following content:

---
testspace:
before:
name: github::fixture
description: example input
input:
a: one
b: two
---

# Use Setup Fixture
This is a manual test.

## Test Case One
Some description here.

* check this
* check that

## Test Case Two
Some description here.

* check this
* check that

Workflow

In this example, we are using a GitHub Workflow to run handler.js, which implements the required setup.

The .github/workflows/fixture.yml file contains the following content:

name: Testspace
on:
workflow_dispatch:
inputs:
name:
description: 'Function name'
required: true
payload:
description: 'Function input-payload'
required: true
context:
description: 'Function execution-context'
required: true
env:
IN_NAME: ${{ github.event.inputs.name }}
IN_PAYLOAD: ${{ github.event.inputs.payload }}
IN_CONTEXT: ${{ github.event.inputs.context }}
jobs:
fixture:
if: github.event.inputs.name == 'fixture'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Call Script implementing setup fixture
run: node ./.github/workflows/handler.js

Handler

In our example, a generic handler will be implemented in JavaScript, but the concept applies to all languages supported by GitHub Actions.

The generic handler being used simply logs the input parameters.

The .github/workflows/handler.js file contains the following content:

function handler(payload) {

console.log("SETUP Handler running ..");
console.log("Payload: ", payload.a, payload.b);
}

handler(JSON.parse(process.env.IN_PAYLOAD));

Execute

The current test specs listing reflects the status of previous sessions and the new Use Setup Fixture spec (defined in specs/use.setup.fixture.md spec file).

To execute click on the Use Setup Fixture spec.

Click on the START button to trigger the automation. While running a spinning icon will appear.

At this point, all test cases can be executed. Once the selected cases have been executed, the session can be completed and any teardown fixures would execute as well.

Recap

Testspace supports integrating automation with manual testing. The following are some key benefits:

  • Reduce manual execution time. Fixturing can leverage automation for tedious and redundant setup/teardown requirements versus human execution.
  • Deploy "hybrid testing" leveraging automation and human observations.
  • Minimize IT setup for Human testers. All testing, including automation, is executed in the context of a web browser.
  • Maintain test specs and automation in the same repo.