whitfin / local-cluster

Easy local cluster creation for Elixir to aid in unit testing
MIT License
226 stars 30 forks source link

Update the readme to show ExUnit.start can run before LocalCluster.start ? #9

Closed toranb closed 5 years ago

toranb commented 5 years ago

I was following the readme to the letter recently by running LocalCluster.start before my ExUnit.start in the test_helper (Phoenix) but ... strangely enough it turns out you can run the LocalCluster.start in a single setup for just 1 test meaning the ExUnit.start can remain in the test_helper as you would see in any default application layout.

Any reason we can't update the readme to reflect this^ world view?

note: working example app w/ my results to prove its fine running after ExUnit.start

https://github.com/toranb/elixir-budget/commit/b657a1824dbc9db2f6ea4bf5ce62460173e4b423

whitfin commented 5 years ago

You don't see an issue because you only have one test using the cluster. If you have 5 tests and call LocalCluster.start in each one, it's going to have a large overhead against doing it once before your tests run. It runs before ExUnit to guarantee that the library is correctly started before running any tests that depend on it. The README is written for the general case, as there's pretty much no benefit to doing it directly inside a test.