Towards Better Test Coverage: Merging Unit Tests for Autonomous Systems

Josefine Graebener, Apurva Badithela, Richard M. MurrayarXiv 2022

TL;DR

This paper introduces a formal framework to merge multiple autonomous system unit tests into a single test execution using contract-based design theory. By combining test specifications and applying a scalable, receding horizon filter to guide Monte-Carlo Tree Search (MCTS), the approach significantly reduces the number of test runs needed to achieve high coverage without sacrificing testing rigor.

What Problem Does This Paper Address?

Testing autonomous systems, such as self-driving cars, is notoriously difficult, expensive, and time-consuming. The real world presents an infinite variety of operating environments, making exhaustive testing computationally and financially intractable.

While current "falsification" techniques excel at finding edge cases that break a system, they typically evaluate only one requirement at a time. This results in massive, inefficient test campaigns where vehicles must be tested repeatedly across hundreds of individual scenarios. The authors address a fundamental question: Is it possible to validate multiple system requirements simultaneously in a single test execution?

To achieve this, the combined test must be carefully designed so it doesn't allow requirements to be satisfied "vacuously" (e.g., bypassing one test condition entirely because another was met), all while ensuring the test generation algorithm remains computationally scalable.

Methods

The authors formalize a test using three attributes: a test specification (written in Linear Temporal Logic, specifically Generalized Reactivity of rank 1, or GR(1)), a test environment, and a test policy.

The core pipeline consists of four main steps:

  1. Contract-Based Merging: The authors leverage the strong merge operator from assume-guarantee contract theory to combine two separate unit test specifications into a single, joint contract.
  2. Temporal Constraints: To prevent one test from trivially satisfying the other, they introduce explicit temporal constraints. This ensures that both test conditions are checked independently and non-trivially during the execution.
  3. Auxiliary Game Graph & Receding Horizon Filter: They construct an auxiliary graph representing the merged specifications. To ensure scalability, they synthesize a test policy filter using a receding horizon approach. This filter identifies the "winning set" of states from which the test environment can guarantee the test goals will be met.
  4. Guided MCTS: Finally, they use Monte-Carlo Tree Search (MCTS) to find a reactive test policy that maximizes a robustness metric (making the test as challenging as possible) while using the synthesized filter to prune out any actions that would violate the test specification.
Overview of the proposed test-merging framework.

Datasets

The paper does not use standard external datasets. Instead, the authors evaluate their framework using two custom discrete gridworld simulation examples implemented in Python using the Temporal Logic and Planning Toolbox (TuLiP):

  • Lane Change Scenario: An autonomous car must merge into a lane specifically between two environment cars, combining the unit tests of "merging in front of a car" and "merging behind a car."
  • Unprotected Left-Turn Scenario: An autonomous vehicle must navigate an intersection while waiting for both an oncoming car to pass and a pedestrian to cross the street.

Key Insights and Ideas

  • Avoiding Vacuous Satisfaction: Simply running two tests at the same time isn't enough. For instance, if Test A requires waiting for a car and Test B requires waiting for a pedestrian, a simple conjunction might allow a single stop to satisfy both simultaneously without truly testing the system's distinct reactions to each agent. The addition of explicit temporal constraints forces the environment to test both requirements distinctly.
  • The Power of the Filter: Standard MCTS can easily get lost in large state spaces. By using a receding horizon safety/progress filter, the search space is dramatically restricted to only valid test trajectories. This ensures the generated test policy is mathematically guaranteed to be sound while accelerating search performance.

Key Results

  • Soundness Proof: The authors mathematically prove that their algorithm is sound—any test execution generated using their filter is guaranteed to satisfy the merged test specification.
  • Scalability Boost: In the lane change example, computing a full-horizon winning set failed for a track length of 11 due to state-space explosion. In contrast, the receding horizon approach easily scaled past a track length of 13 while maintaining low computation times.
  • Rapid Convergence: Thanks to the filter constraining the search space, the MCTS algorithm converged to the maximum robustness test policy with very few rollouts (often requiring fewer than 3–5 rollouts to find the optimal policy).
The lane change scenario showing initial and final configurations for merging in front, behind, or between tester agents.

Limitations and Future Work

  • Discrete State Spaces: The current implementation is restricted to discrete gridworld environments. The authors note that extending this framework to continuous dynamical systems (via discrete abstractions) is a crucial next step.
  • Pairwise Merging: The framework currently focuses on merging two unit tests at a time. Scaling this up to optimally group and merge $N$ unit tests into the minimum possible number of test executions remains an open combinatorial problem.
  • Symbolic Optimization: The scalability of the filter synthesis could be further enhanced by incorporating symbolic implementations rather than explicit state-space representations.

Summary updated

BibTeX
@misc{graebener2022towards,
  author = {Josefine Graebener and Apurva Badithela and Richard M. Murray},
  title = {{Towards Better Test Coverage: Merging Unit Tests for Autonomous Systems}},
  year = {2022},
  eprint = {2204.02541},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.02541},
}
Figure