From a2f371b9c3ae98d7ecf9630fbe25234d278b816f Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 19 Mar 2019 16:37:23 -0500 Subject: [PATCH] Add Run The Test At A Specific Line Number as an elixir til --- README.md | 3 ++- .../run-the-test-at-a-specific-line-number.md | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 elixir/run-the-test-at-a-specific-line-number.md diff --git a/README.md b/README.md index fe962ec..e1675ac 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_788 TILs and counting..._ +_789 TILs and counting..._ --- @@ -158,6 +158,7 @@ _788 TILs and counting..._ - [Root Directory Of A Project](elixir/root-directory-of-a-project.md) - [Round Floats To Integers](elixir/round-floats-to-integers.md) - [Run ExUnit Tests In A Deterministic Order](elixir/run-exunit-tests-in-a-deterministic-order.md) +- [Run The Test At A Specific Line Number](elixir/run-the-test-at-a-specific-line-number.md) - [Same Functions Should Be Grouped Together](elixir/same-functions-should-be-grouped-together.md) - [String Interpolation With Just About Anything](elixir/string-interpolation-with-just-about-anything.md) - [Unique Indexes With Ecto](elixir/unique-indexes-with-ecto.md) diff --git a/elixir/run-the-test-at-a-specific-line-number.md b/elixir/run-the-test-at-a-specific-line-number.md new file mode 100644 index 0000000..7c09a59 --- /dev/null +++ b/elixir/run-the-test-at-a-specific-line-number.md @@ -0,0 +1,25 @@ +# Run The Test At A Specific Line Number + +You can tell `mix test` to only run tests that appear in a specific file by +naming the file: + +```bash +$ mix test test/module/file_test.exs +``` + +You can even point it to a specific line number in that file like so: + +```bash +$ mix test test/module/file_test.exs:45 +``` + +Behind the scenes, `mix test` is using tags to build a list of exclusions +and inclusions that result in only the test at line 45 running. Here is an +equivalent of the above command: + +```bash +$ mix test test/module/file_test.exs --exclude test --include line:45 +``` + +This will exclude every test. It will then re-include the test that +corresponds to having a tag `line:45`.