Sleepful
What mode do you prefer for Ecto.Adapters.SQL.Sandbox? (Ecto + ExUnit)
So I was reading of the multiple modes for Ecto.Adapters.SQL.Sandbox, it seems you have to use only one of the modes for your test suite so you have to pick one of the three options available: :auto (default), :manual or :shared.
Trying to figure out which is the best, so I want to poll opinions ![]()
Found this related article which explains it a little more Making Sense of Ecto 2 SQL.Sandbox and Connection Ownership Modes
Most Liked
JohnnyCurran
The links you shared are a little out of date
The updated documentation is at Ecto.Adapters.SQL.Sandbox — Ecto SQL v3.14.0 - Your version is Ecto 2.0 beta. Ecto is now on version 3.9
You probably want to leave it on :auto or set it to :manual - I set it to :manual in test_helpers.exs
If you use :shared, you can no longer run your tests async. This is because :shared mode can introduce non-determinism because the test processes / transactions can see each of the other test transactions data it has inserted into the database. See 8 Common Causes of Flaky Tests in Elixir | AppSignal Blog for more info (#2 in the list)
Last Post!
Sleepful
This makes me think of another question… Can you mix modes for different tests or is that bound to cause chaos?
Trending in Discussions
Other Trending Topics
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #elixirconf-us
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










