How To Mimic Golang Test Structure?

I like how to golang convention to put test file next to source.
Is there any way to do the same using mix test?

I remember have read an article regarding to that, but unable to find it.

Sounds messy, but I’d think you could do it by adjusting the test pathing in mix.exs? (Probably no modification necessary…)

1 Like

I think go actually doing good there, especially if we really into TDD.

Apparently I can’t make it work without modification. Unable to find any sample on how to add config to mix test in docs :confused:

For those who looking, this is how I did it:

  1. Add test_paths: ["."] in mix.exs's def project list
  2. Move test_helper.exs from test/ to project’s root, next to mix.exs
  3. Run mix test, now it will glob like go test ./...

Cheers!

3 Likes