Supertester.UnifiedTestFoundation (supertester v0.1.0)

View Source

Unified test foundation providing multiple isolation modes for OTP testing.

This module provides macros and utilities to establish different levels of test isolation, enabling async testing while preventing process conflicts and ensuring proper cleanup.

Isolation Modes

  • :basic - Basic isolation with unique naming
  • :registry - Registry-based process isolation
  • :full_isolation - Complete process and ETS isolation
  • :contamination_detection - Isolation with contamination detection

Usage

defmodule MyApp.MyModuleTest do
  use ExUnit.Case
  use Supertester.UnifiedTestFoundation, isolation: :full_isolation

  test "my test", context do
    # Test runs with full isolation
  end
end

Summary

Functions

Provides test isolation setup based on the specified isolation type.

Returns whether the isolation type allows async testing.

Returns the timeout for the isolation type.

Sets up test isolation based on the specified isolation type.

Verifies test isolation has been maintained.

Waits for a supervision tree to be ready.

Functions

__using__(opts)

(macro)

Provides test isolation setup based on the specified isolation type.

isolation_allows_async?(atom)

@spec isolation_allows_async?(atom()) :: boolean()

Returns whether the isolation type allows async testing.

isolation_timeout(atom)

@spec isolation_timeout(atom()) :: non_neg_integer()

Returns the timeout for the isolation type.

setup_isolation(isolation_type, context)

@spec setup_isolation(atom(), map()) :: {:ok, map()}

Sets up test isolation based on the specified isolation type.

verify_test_isolation(context)

@spec verify_test_isolation(map()) :: boolean()

Verifies test isolation has been maintained.

wait_for_supervision_tree_ready(supervisor_pid, timeout \\ 5000)

@spec wait_for_supervision_tree_ready(pid(), non_neg_integer()) ::
  {:ok, pid()} | {:error, :timeout}

Waits for a supervision tree to be ready.