Skip to main content
FixturFab

Test Plans

Learn how to structure and create test plans with pytest-f3ts for organized, maintainable hardware testing.

Test plans in pytest-f3ts provide structure for organizing hardware tests into logical groups with shared configuration and execution order.

Anatomy of a Test#

A test evaluates whether system behavior matches expected results. The process breaks down into four stages:

  1. Setup: Prepare everything needed for the test, including initializing hardware interfaces and configuring test equipment.

  2. Act: The critical action that triggers the behavior being tested, altering the Device Under Test (DUT) state through signals, input parameter changes, or hardware function triggers.

  3. Assert: Examine the resulting state post-action and assess whether it aligns with our expectations. This involves verifying outputs, checking protocols, and confirming circuit performance.

  4. Teardown: Reset the test environment to prevent interference with subsequent tests by clearing states, data, or shutting down equipment.

Test Plan Structure#

A pytest-f3ts test plan consists of five key components:

config.yml#

Configuration file containing test limits, interface settings, and runner parameters to define customizable testing thresholds.

conftest.py#

Standard pytest configuration file defining the test interface fixture and other pytest-specific settings for hardware interaction.

test_plan.py#

Contains actual test case functions that leverage the defined interfaces and configurations to interact with hardware and verify outcomes.

interface.py#

Module defining the test interface for all instrumentation and hardware, encapsulating low-level hardware interactions.

pyproject.toml#

Project configuration for Poetry dependency management, listing packages required for the testing framework.

Creating a Test Plan#

Suggested Directory Structure#

Organize your test plan project with these key files:

fixture_controller_functional_test/
├── config.yml
├── conftest.py
├── test_plan.py
├── interface.py
└── pyproject.toml

Setup Steps#

  1. Create new project directory
  2. Run poetry init
  3. Add pytest-f3ts as a dependency via poetry add pytest-f3ts
  4. Create config.yml with test name
  5. Develop interface.py with TestInterface class
  6. Write test_plan.py with test cases
  7. Configure conftest.py with pytest fixtures

interface.py Template#

import logging
import os
 
class TestInterface:
    def __init__(self):
        """Initialize test and measurement devices"""
        pass
 
    def close(self):
        """Teardown all hardware"""
        pass

conftest.py Template#

import pytest
from interface import TestInterface
 
@pytest.fixture(scope="session")
def test_fixture(request):
    """Session-scoped fixture for hardware interface"""
    interface = TestInterface()
 
    def teardown():
        interface.close()
 
    request.addfinalizer(teardown)
    return interface

Running Tests#

To run the test plan, use the following command:

poetry run pytest -p pytest_f3ts --config config.yml

Example Project#

An example project for FixturFab's FixturCtrl is available on GitLab for practical implementation guidance.

Last updated:January 24, 2025