Skip to content

Filter ExUnit tests by name #6584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
glittershark opened this issue Sep 19, 2017 · 2 comments
Closed

Filter ExUnit tests by name #6584

glittershark opened this issue Sep 19, 2017 · 2 comments

Comments

@glittershark
Copy link

Precheck

Environment

  • Elixir & Erlang versions (elixir --version):
    Erlang/OTP 20 [erts-9.0.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]

Elixir 1.5.1


Maybe I'm missing something, but it doesn't look like it's possible to filter running tests (ie via mix tests) by their full name. I took a look in the source and it looks like something like the following patch would work:

diff --git a/lib/ex_unit/lib/ex_unit/case.ex b/lib/ex_unit/lib/ex_unit/case.ex
index a54402077..bbdb1f5f1 100644
--- a/lib/ex_unit/lib/ex_unit/case.ex
+++ b/lib/ex_unit/lib/ex_unit/case.ex
@@ -452,7 +452,7 @@ defmodule ExUnit.Case do
       |> normalize_tags
       |> validate_tags
       |> Map.merge(%{line: line, file: file, registered: registered, async: async,
-                     describe: describe, describe_line: describe_line, type: type})
+                     describe: describe, describe_line: describe_line, type: type, name: name})

     test = %ExUnit.Test{name: name, case: mod, tags: tags, module: mod}
     Module.put_attribute(mod, :ex_unit_tests, test)

But I'm not sure how to go about testing it

@josevalim
Copy link
Member

The test name and module are already added to the tags automatically later on: https://github.com/elixir-lang/elixir/blob/master/lib/ex_unit/lib/ex_unit/runner.ex#L138

@glittershark
Copy link
Author

holy crap you're fast.
That's awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants