⚠️ This post links to an external website. ⚠️
Last week, a developer optimized their Elixir/Phoenix test suite, reducing runtime from 313 seconds to 64 seconds. Key improvements included making tests async, which dramatically increased concurrency. Previously, 134 of 940 test files were running asynchronously, harming performance. By flipping to ~830 async files, the process spent less time aggregating results and more time executing tests in parallel.
They also eliminated redundant work by moving pre-seeded database rows to the committed test database, which avoided unnecessary setup during each test and reduced test time significantly. Other optimizations included stubbing external API calls to prevent slowdowns, managing process-global state for safer async execution, and ensuring proper pool size configurations for concurrent database access. The article emphasizes measuring performance before and after changes and treating flaky tests as serious bugs that need fixing.
continue reading onzarar.dev
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.