Skip to content

Unit Tests include "Ippl.h" and don't use mocks/stubs #399

@JoMee

Description

@JoMee

Issue 1: Unit test TUs include entire project

Description:

Each unit test file currently includes the full project headers (through including "Ippl.h"). This leads to:

  • Slow rebuilds: each change to IPPL causes all unit tests to be recompiled.
  • Unnecesary coupling: Tests depend on unrelated parts of the project.

Proposal:
Replace the inclusion of Ippl.h with a minimal set of headers required for the test

Benefits:

  • Faster rebuilds.
  • Clearer communication what the unit test is related to.

Issue 2: Unit tests don’t isolate components (no mocks/stubs)

Our current "unit" tests run against the full codebase; If we want to test something that interacts with an ippl::Field, we build against IPPL's actual implementation of a Mesh, FieldLayout, Field, partitioning strategy and (more subtly) IPPLs Comms object. This causes the following issues:

  • Failures are more difficult to trace: If someone introduces a bug in ippl::Field, it might only show up in a unit test related to interpolation.
  • Unclear contracts: Because components are always tested together, we aren’t forced to be precise about each component’s guarantees and interface. This makes components less modular and makes refactoring riskier.

Proposal:

  • Introduce some helper code building mocks/stubs in order to facilitate the writing of unit tests in isolation.
  • Keep current unit tests but treat them as integration tests.
  • Reimplement them again using mocks/stubs.

Benefits:

  • True "unit" tests that validate components in isolation.
  • Clearer definition of each component’s guarantees and interfaces.
  • Easier/safer refactoring.
  • Faster to recompile and execute test-suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions