ExUnit: Raise or warn if there are files in the test directory that end in `_test.ex`

47 views
Skip to first unread message

Paul Smith

unread,
Sep 17, 2015, 3:40:20 PM9/17/15
to elixir-lang-core
I was recently bitten by this. The `s` was left off at the end. So when I ran `mix test` everything passed correctly. In reality my new test was broken, but I didn't realize it because it wasn't being run. Eventually I caught on to what was happening, but it would have been nice to recognize it sooner.

I think if a test ends in `_test.ex` instead of `_test.exs` it might be a good idea to raise or warn. Maybe this conflicts with something though? Thoughts on how to help people avoid this problem?

Paul

Jason M Barnes

unread,
Sep 17, 2015, 4:04:24 PM9/17/15
to elixir-l...@googlegroups.com
Not a technical solution, but I find it useful to write a failing test first.  That way I know the new test is being run.

Jason

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/614459dd-15a4-4691-b1dd-fb54c4c79c3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Smith

unread,
Sep 17, 2015, 4:11:01 PM9/17/15
to elixir-lang-core
Excellent point, Jason! This would catch this type of thing in most cases. It's still a problem though. I've been bitten by this in various ways.

Example:

* Write failing test in `test/my_failing_test.ex` -> note the missing `s`
* Use tab completion to run `test/my_failing_test.ex` to run it
* Fix the failures
* Run it again
* Run `mix test`

Everything is green! The problem is that when you run the test directly it works, but when you run `mix test` it skips over it. So a few commits later the test could break and you wouldn't know it until you ran that test directly :S

José Valim

unread,
Sep 17, 2015, 4:22:10 PM9/17/15
to elixir-l...@googlegroups.com
We could warn, yes. Please open up an issue, potentially a pull request. :)


José Valim
Skype: jv.ptec
Founder and Director of R&D

Josh Adams

unread,
Sep 17, 2015, 4:23:42 PM9/17/15
to elixir-l...@googlegroups.com
It sounds like a nice bit of UI for the language to me. Should be a
relatively easy thing to send in a PR for :) :)
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-co...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/614459dd-15a4-4691-b1dd-fb54c4c79c3e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Josh Adams

Paul Smith

unread,
Sep 17, 2015, 5:47:12 PM9/17/15
to elixir-l...@googlegroups.com
Awesome! I started on the PR https://github.com/elixir-lang/elixir/pull/3750 would love some feedback on how to test this. It is probably simple, but I can’t quite figure it out. I tried running `make test` but that appears not to use `mix test`, either that or my code isn’t working as I expect.


You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/yfWemHZfiq0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAA1-O0wRNrp7WoCNdHP9n2VmhF5ZpdPKRDxcyhXPeKHGn2KB0w%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages