GitHub

An educational repository demonstrating Elixir testing patterns through a simple Todo API application.

About

This repository is a companion to a 7-part blog series on Elixir testing patterns. Each PR corresponds to one blog post and introduces specific testing concepts.

Quick Start

# Enter Nix development shell (if using Nix)
nix develop
# Setup project (install deps + create database)
just setup
# Run tests
just test
# Start server
just server

Available Commands

Run just to see all available commands:

  • just setup - Install dependencies and setup database
  • just test - Run all tests
  • just server - Start Phoenix server
  • just check - Run format and compile checks
  • just format - Auto-format code

Project Structure

lib/
├── ex_test/
│   ├── todos/
│   │   └── todo.ex      # Todo schema
│   └── todos.ex         # Todos context (CRUD operations)
└── ex_test_web/
    └── ...              # Phoenix web layer
test/
├── ex_test/
│   └── todos_test.exs   # Context tests
└── support/
    ├── data_case.ex     # Database test case
    └── fixtures/        # Test fixtures

Requirements

  • Elixir 1.17+ (1.19 via Nix flake)
  • SQLite3

Blog Series

PR Topic
PR-00 Project Setup (this PR)
PR-01 Introduction to Testing with ExUnit
PR-02 Database Testing with Ecto.Sandbox
PR-03 Factory Patterns with ExMachina
PR-04 Behavior-Driven Mocking with Mox
PR-05 Adapter Pattern & Stubs
PR-06 Centralized Test Helpers
PR-07 Testing Phoenix Controllers

License

MIT

Read the original on github.com ↗