https://github.com/cybrox/mix-phxtest
Mix command for easily running specific tests in phoenix
https://github.com/cybrox/mix-phxtest
elixir elixir-mix elixir-phoenix mix-tasks tdd testing
Last synced: about 1 year ago
JSON representation
Mix command for easily running specific tests in phoenix
- Host: GitHub
- URL: https://github.com/cybrox/mix-phxtest
- Owner: cybrox
- Created: 2018-05-15T12:30:45.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-17T12:00:33.000Z (about 8 years ago)
- Last Synced: 2025-03-01T17:49:07.292Z (over 1 year ago)
- Topics: elixir, elixir-mix, elixir-phoenix, mix-tasks, tdd, testing
- Language: Elixir
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mix phxtest
Mix task for running specific tests in your [phoenix](https://github.com/phoenixframework/phoenix) project via `mix test` (ex_unit) and `mix watch` ([mix-test.watch](https://github.com/lpil/mix-test.watch)) more conveniently.
Let's admit it, we're all lazy and running specific tests in a phoenix project can be a bit of a hassle when specifying the full path. I for one, would prefer to strip the boilerplate text from the command. So, here's a fitting library.
```
# Stop doing this
$ mix test test/myapp_web/controllers/resource_controller.exs:12
# Start doing this
$ mix phxtest c resource 12
```
Just add `mix_phxtest` as a dependency to your project via [hex.pm](https://hex.pm/packages/mix_phxtest)
```
{:mix_phxtest, "~> 0.2.2", only: [:test]}
```
### Usage
```
Usage: mix phxtest [line]
mix phxwatch [line]
type: c - controller (/test/myapp_web/controllers/)
v - view (/test/myapp_web/views/)
p - plug (/test/myapp_web/plug/)
w - web (/test/myapp_web/)
l - lib (/test/myapp/)
name: The name of your file, you can add additional
subdirectories here, if needed.
line: The line of the test, if you only want to execute
a single test. This is optional.
idea: The phx.test and phxwatch are just aliases that
perform simple string interpolation. The commands
you are generating are composed like this:
$ mix phxtest c user 12
$ mix test /test/controllers/user_controller_test.exs:12
```
Hint: You can access nested tests by putting the path in the name parameter:
```
$ mix phxtest c device/mobile 11
# Will become
$ mix test test/myapp_web/controllers/device/mobile_controller_test.exs:11
```