Trending in Blog Posts
My first real blog post is up! Got five minutes? Come break some stuff. I put five demos in it, and they’re meant to be played with. Kill...
New
I run a kanban of AI coding agents, and one afternoon the board showed three tasks running while the profile page on the same screen said...
New
I wrote a post on how to implement a feature flag system and A/B testing in an Elixir app with no need for third-party services or librar...
New
Following up on Making `dns_erlang` fast: binary tricks for the BEAM, there’s our second post in our series on making erldns, an authorit...
New
A small quality-of-life improvement to my blog that makes it easier to keep technical posts up to date with a revision history.
https://...
New
Wrote a post about how I set up HTML email templates in Phoenix using the template renderer with Gettext and verified routes, CSS inlinin...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #security
- #elixirconf-eu
- #processes
- #api
- #forms
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
rhcarvalho
Thanks for sharing!
I was surprised that at the end you replaced something that created loose relations (ExMachina) with something that creates eagerly tight relations (SeedFactory)
My experience is that sometimes you need one behavior, sometimes the other, and sometimes something in between.
The explicit state construction you had in the middle of the article felt like the best way to demonstrate intent in the tests!
Building on one of your examples, in the same test file you may want to construct a project such that owner and manager users are the same, and another one where they are different. You may even need to test some rule related to their relative attributes (e.g. say that if the manager is newer than the owner then something special applies to the project).
Why not leave the decision of how to construct state to be a local decision per-project, per-test/describe/module?
mudasobwa
As a big fan of property-based testing, I use my
estructuralibrary to generate data.fuelen
I would not call it loose vs tight, rather invalid vs valid. The tight graph is a side effect of reusing what is already in the context, not the goal.
What to construct is still decided in the test. The schema centralizes how and gives a sane default, so the part a test does not care about is not repeated in every test. You decide what that default is, and it should be the graph that repeats most in your application. Where a test needs another branch, it goes there with
exec.produceis built on top ofexec, and they are meant to be mixed.produceis for “give me a project, any project”. Where the order or the specifics matter, you writeexec:Your example with the manager newer than the owner goes the same way, with the dates as parameters to
exec. When a variation repeats across tests, it becomes a trait. A trait is an alias for anexeccall, so a test can writeproduce(ctx, user: [:registered_early, as: :owner])instead.For the “something in between”, the context is a plain map, so forking it means using the same variable twice:
Both projects share the organization and nothing else
rhcarvalho
Thanks. The additional examples also made realize another nice aspect of your solution: explicit context, so two tests don’t share a global execution order (which would be flaky), right?
fuelen
Right, tests can be async.