Thanks Sasa, Jose,
Both solutions work!
More importantly, both pushed me to learn more Elixir!
Here's a few comments / questions....
1) Using mix test --no-start
Cool, I didn't realize that was there.
When I tried this, I got an error for the Logger application not running.
Fixed that with Application.start(:logger).
It seemed to make sense to move it to the test_helper.exs, which works.
But it doesn't look like you can move the start option to the test helper because its used earlier in the app.start.
It feels like it might be inflexible as your app mature because
I think you'd be committed to using --no-start all the time.
Would it make sense to have something for default Mix cli options? like a '.mix' file.
I'm not sure it's needed...just thinking out loud :-)
Again this works great.
2) Passing agent name in args.
I was happy how close my Agent was to Jose's example :-)
I went with this approach. It does make the tests a little more wordy, but not bad.
I noticed I didn't have to use on_exit.
So, the Agent is stopped when the test process dies?
thanks again !
setup do
{:ok, agent} = ConsumerAgent.start_link name: {:global, __MODULE__ }
{:ok, agent: agent}
end
test "get current consumer key", context do
assert ConsumerAgent.get(context[:agent]) == 0
end
...