feat(testing): add centralized test helper modules (#6)#7
Merged
Conversation
Introduces centralized helper modules for cleaner, more maintainable tests: - StubHelper: Centralized stub configuration (with_email_success, with_storage_failure, etc.) - AssertHelper: Domain-specific assertions (assert_todo_valid, assert_changeset_error, etc.) - SetupHelper: Reusable setup functions (with_todo, with_mixed_todos, etc.) All helpers are auto-imported via DataCase for seamless usage. Patterns Demonstrated: - Composable setup with named functions: setup [:with_email_success, :with_todos] - Assertion chaining: todo |> assert_todo_valid() |> assert_todo_incomplete() - Context-aware setup functions for ExUnit's setup macro Blog Post: Part 6 - Centralized Test Helpers
rakshans1
added a commit
that referenced
this pull request
Dec 25, 2025
Introduces Phoenix controller testing with ConnCase: - User schema and context for auth simulation - TodoController with full CRUD operations - TodoJSON for JSON rendering - FallbackController for error handling - ConnSimulator for authentication helpers - Comprehensive controller tests Patterns Demonstrated: - ConnCase template usage - JSON response assertions - Testing CRUD operations - Error case testing (404, 422) - Authentication simulation Blog Post: Part 7 - Testing Phoenix Controllers
rakshans1
added a commit
that referenced
this pull request
Dec 25, 2025
Introduces Phoenix controller testing with ConnCase: - User schema and context for auth simulation - TodoController with full CRUD operations - TodoJSON for JSON rendering - FallbackController for error handling - ConnSimulator for authentication helpers - Comprehensive controller tests Patterns Demonstrated: - ConnCase template usage - JSON response assertions - Testing CRUD operations - Error case testing (404, 422) - Authentication simulation Blog Post: Part 7 - Testing Phoenix Controllers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR-06: Centralized Test Helpers
Overview
Creates centralized helper modules for cleaner, more maintainable tests.
Patterns Demonstrated
Files Added
test/support/stub_helper.ex- Stub configuration helperstest/support/assert_helper.ex- Custom assertionstest/support/setup_helper.ex- Reusable setup functionstest/ex_test/helpers_demo_test.exs- Demo test (22 tests)Files Modified
test/support/data_case.ex- Import all helper modulesUsage Example
How to Run
mix test test/ex_test/helpers_demo_test.exsBlog Post
This PR corresponds to Part 6: Centralized Test Helpers.
Next Steps
PR-07 will introduce Phoenix controller testing.