Elixir: mix test pointed to describe block line of code runs wrong tests.

Created on 25 Jul 2017  路  11Comments  路  Source: elixir-lang/elixir

Environment

  • Elixir & Erlang versions (elixir --version): 1.5.0, r19
  • Operating system: macOS Sierra 10.12.5

As a setup, I have the following file:

defmodule FileLocationTest do
  use ExUnit.Case

  describe "describe 1" do # line 4
    test "test 1" do
      IO.puts "in test 1"
    end
  end

  describe "describe 2" do # line 10
    test "test 2" do
      IO.puts "in test 2"
    end
  end
end

Current behavior

When runningmix test test/file_location_test:4, all tests are skipped.

When runningmix test test/file_location_test:10, the terminal output is in test 1.

Expected behavior

When runningmix test test/file_location_test:4, the terminal output should be in test 1.

When runningmix test test/file_location_test:10, the terminal output should be in test 2.

ExUnit Enhancement Unresolved

Most helpful comment

I am confused by the documentation

https://hexdocs.pm/ex_unit/ExUnit.Case.html#describe/2-examples

mix test --only describe:"String.capitalize/1"

This sort of works for me unless i have spaces in the describe string.

mix test --only describe:"My interesting describe"

results in including tag "My" rather than the whole string.

Including tags: [describe: "My"]
Excluding tags: [:test]

All 11 comments

For now Mix only allows pointing to the tests themselves, not to describe groups.

Cool, thanks for coming back to me!

For now Mix only allows pointing to the tests themselves, not to describe groups.

Hmm, that could be a useful feature though thinking about it. Would you be interested in a PR if anyone did one? (Not me, in another crunch period at work, otherwise if someone reminds me later I can.)

If someone does it we will be glad to accept it depending on the code complexity.

I am confused by the documentation

https://hexdocs.pm/ex_unit/ExUnit.Case.html#describe/2-examples

mix test --only describe:"String.capitalize/1"

This sort of works for me unless i have spaces in the describe string.

mix test --only describe:"My interesting describe"

results in including tag "My" rather than the whole string.

Including tags: [describe: "My"]
Excluding tags: [:test]

@dustinfarris what operating system are you using?

@dustinfarris and can you fix it by including the describe in the quotes?

mix test --only "describe:My interesting describe"

@josevalim no, including the describe in quotes does not change anything. Continues with above behavior.

macOS Sierra, using ZSH shell, elixir 1.4.4

Then it will be up to escaping in your shell. You need to find a way to quote the arguments such as the command below returns a single list, as shown:

$ elixir -e "IO.inspect System.argv" -- "describe:My test"
["describe:My test"]

That works, but the test command does not :-/

Was this page helpful?
0 / 5 - 0 ratings