elixir-lang/elixir — pull request #2926 by xavier (2014-12-06 17:27:47+00:00)
Title: Execute tests having the same name

Currently, if several tests have the same name (it can very easily happen accidentally), only the first test is executed and other tests are silently ignored, leaving the user with a false sense of security.

For instance, if you run the test added to `ex_unit_test.exs` on master, it will fail as follow:

```
1) test it executes different tests having the same name (ExUnitTest)
test/ex_unit_test.exs:105
Assertion with == failed
code: ExUnit.run() == %{failures: 1, skipped: 0, total: 2}
lhs: %{failures: 0, skipped: 0, total: 2}
rhs: %{failures: 1, skipped: 0, total: 2}
stacktrace:
(ex_unit) lib/ex_unit/capture_io.ex:99: ExUnit.CaptureIO.do_capture_io/3
test/ex_unit_test.exs:118
```

Two tests were added to the list but only the first one got executed (twice, because of the pattern matching rules).

To solve this issue, this patch ensures that all tests (and thus the generated test functions) have a unique name.

Note: It's a bit unfortunate that this small internal change has a (limited) visible effect to the user (see changes in `doc_test_test.exs`). But I'm afraid that completely decoupling the displayed test name from the function name would have been a change with a much larger impact than this.