elixir-testing

Automate Elixir tests with Ecto.SQL.Sandbox and background process handling.

1|1|Updated Feb 8, 2026
One-click install
npx skills add https://github.com/code0100fun/botfiles --skill elixir-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: elixir-testing
Source: https://github.com/code0100fun/botfiles/tree/main/plugins/elixir-phoenix/skills/elixir-testing
Command: npx skills add https://github.com/code0100fun/botfiles --skill elixir-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide provides production-ready patterns for testing Elixir applications using Ecto.SQL.Sandbox, focusing on reliable test isolation and proper handling of background processes and Oban.

Core Features & Use Cases

  • Manual mode with selective shared mode via test tags to enable fast unit tests and safe integration tests.
  • Guidance for managing background processes (GenServers, Oban workers) in tests and ensuring automatic cleanup with start_supervised!/1 and start_owner!/2 patterns.
  • Oban testing configuration and patterns to separate enqueueing from execution for deterministic tests.
  • Guidance for avoiding global shared mode and for configuring test environments to maximize performance and reliability.

Quick Start

Configure your tests to run with Ecto.Adapters.SQL.Sandbox in manual mode and selectively enable shared mode, then run the test suite to verify isolation and background process handling.

Frequently Asked Questions about elixir-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test Elixir background processes without database transaction leaks?

Testing Elixir background processes safely requires sandboxed database isolation. You can use Ecto.SQL.Sandbox in manual mode with start_owner!/2 and start_supervised!/1 patterns to ensure automatic cleanup and prevent transaction leaks across GenServers and Oban workers.

What is the best way to configure Ecto.SQL.Sandbox for fast unit and integration tests?

The best way to configure Ecto.SQL.Sandbox is using manual mode by default and selectively enabling shared mode via test tags. This strategy maximizes performance for fast unit tests while ensuring safe, isolated integration tests when concurrent database access is required.

How do I configure Oban workers for deterministic testing in Elixir?

Deterministic Oban testing involves separating job enqueueing from execution. You can configure Oban testing patterns to isolate worker behavior, ensuring background jobs do not execute unexpectedly during Ecto.SQL.Sandbox test runs and yielding predictable, reliable test outcomes.

Why should I avoid global shared mode when testing Elixir applications with Ecto?

Global shared mode degrades test performance and reliability by allowing unrestricted concurrent database access across all tests. Avoiding it and using selective shared mode via test tags maintains strict test isolation while preserving the speed of manual mode for standard unit tests.

Can I use Ecto.SQL.Sandbox with Oban and supervised GenServers in the same test?

Yes, you can use Ecto.SQL.Sandbox with Oban and GenServers. By leveraging start_owner!/2 for database ownership and start_supervised!/1 for process lifecycle management, tests achieve proper automatic cleanup and reliable database isolation for background processes.