Version 10.4.0
Thanks
- For requesting
espec
support- Don Lettrich (@drl123)
- For reporting missing
runReadAction
- Jim James (@jimjames99)
Changelog
v10.4.0
Enhancements
- #1410
- ESpec Test Runner - alex-dukhno
- ESpec Graphical Test Results - @KronicDeth
Bug Fixes
- #1410 - @KronicDeth
- Only show Run/Debug ExUnit when
*_test.exs
files exist. - Only show Run/Debug ESpec when
*_spec.exs
files exist.
- Only show Run/Debug ExUnit when
- #1415 - Wrap
UnqualifiedNoArgumentCall.quote
identifier.text
inrunReadAction
. - @KronicDeth - #1419 - Fix typos in
CONTRIBUTING.md
- @nschulzke - #1420 - Prevent the module attribute annotator from running in EEx files. - @nschulzke
README Changes
Features
Run/Debug Configurations
mix espec
The mix espec
task gets a special type of Run Configuration, Elixir Mix Espec
. Using this Run Configuration type instead, of the basic Elixir Mix
Run Configuration will cause the IDE to attach a special formatter to mix espec
, so that you get the standard graphical tree of Test Results.
The Run pane will show Test Results. If there is a compilation error before or during mix espec
, it will be shown as a test failure. If the compilation failure is in a _spec.exs
file can it can be inferred from the stacktrace, the compilation error will show up as a test failure in that specific module.
Using graphical formatter
If you override the default formatters you will need to add the following code to your spec_helper.exs
.
If you override formatters similar to below
ESpec.configure fn(config) ->
config.formatters ...
ESpec.configure fn(config) ->
config.formatters [
{ESpec.Formatters.Json, %{out_path: "results.json"}},
{ESpec.Formatters.Html, %{out_path: "results.html"}},
{ESpec.Formatters.Doc, %{details: true, out_path: "results.txt"}},
{ESpec.Formatters.Doc, %{details: true, diff_enabled?: false, out_path: "results-no-diff.txt"}},
{ESpec.CustomFormatter, %{a: 1, b: 2}},
]
end
Replace them with code that checks for the graphical formatter TeamCityESpecFormatter
and uses only it when available.
ESpec.configure fn(config) ->
config.formatters(if Code.ensure_loaded?(TeamCityESpecFormatter) do
[{TeamCityESpecFormatter, %{}}]
else
...
end)
end
ESpec.configure fn(config) ->
config.formatters(if Code.ensure_loaded?(TeamCityESpecFormatter) do
[{TeamCityESpecFormatter, %{}}]
else
[
{ESpec.Formatters.Json, %{out_path: "results.json"}},
{ESpec.Formatters.Html, %{out_path: "results.html"}},
{ESpec.Formatters.Doc, %{details: true, out_path: "results.txt"}},
{ESpec.Formatters.Doc, %{details: true, diff_enabled?: false, out_path: "results-no-diff.txt"}},
{ESpec.CustomFormatter, %{a: 1, b: 2}},
]
end)
end
Creating mix espce
Run Configurations Manually
-
Run > Edit Configurations…
-
Click +
-
Select “Elixir Mix ESpec”
-
Fill in the “
mix espec
arguments” with the argument(s) to pass tomix espec
. Normally, this will be list of*_spec.exs
files, relative to the “Working directory”.NOTE: Unlike
mix test
,mix espec
does not support directories as arguments. -
(Optionally) fill in “
elixir
arguments” with the arguments toelixir
before it runsmix test
. -
(Optionally) fill in "
erl
arguments"with the arguments to
erlbefore it runs
elixir`. -
Fill in the “Working directory”
- Type the absolute path to the directory.
- Select the path using directory picker by clicking the
...
button
-
(Optionally) click the
...
button on the “Environment variables” line to add environment variables. -
Click “OK” to save the Run Configuration and close the dialog
With the Run Configuration defined you can either Run or Debug the mix espec
s
Running
- Click the Run arrow in the Toolbar to run the
mix test
task - The Run pane will open showing the Test Results
Debugging
- (Optionally) before debugging, customize the modules that will be interpreted.
- Run > Edit Configurations…
- Click the “Interpreted Modules” tab next to default “Configuration” tab.
- Enable/Disable “Inherit Application Module Filters”. Will change the Module Filters show in the below “Do not interpreter modules matching patterns” list.
- Uncheck any inherited module filters that you would rather be interpreted and therefore debuggable
- Click + to add module filters that are specific to this configuration. This can be useful if you know interpreting a specific module in your project’s dependencies or project leads to too much slowdown when debugging or causes the debugger to hang/crash.
- Click - to remove configuration-specific module filters added with +. Inherited module filters cannot be removed with -, they can only be disabled by unchecking.
- For how to use the debugger, including how to set breakpoints see the Debugger section.
- Click the Debug bug in the Toolbar to debug the
mix test
s
While you can create Elixir Mix ESpec
run configurations manually using the Run > Edit Configurations...
menu, it is probably more convenient to use the context menu.
Creating mix espec
Run Configurations from context
The context menu must know that the the directory, file, or line you are right-clicking is a test. It does this by checking if the current directory or an ancestor is marked as a Test Sources Root and contains or is a *_spec.exs
file(s)
- In the Project pane, ensure your OTP application’s
espec
directory is marked as a Test Sources Root - Check if the
espec
directory is green. If it is, it is likely a Test Sources Root. This color may differ in different themes, so to be sure you can check the context menu - Right-click the
test
directory. - Hover over “Mark Directory As >”
-
If “Unmark as Test Sources Root” is shown, then the directory is already configured correctly, and create from context will work.
-
If “Test Sources Root” is shown, then the directory need to be configured by clicking that entry
-
Creating/Running mix espec
Run Configurations from directory
-
Right-click the directory in the Project pane
-
Click “Run Mix ExUnit”, which will both create the Run Configuration and Run it.
- If you want to only create the Run Configuration, select “Create Mix ESpec” instead
Alternatively, you can use keyboard shortcuts
- Select the directory in the Project pane.
Ctrl+Shift+R
will create the Run Configuration and Run it.
Creating/Running mix espec
Run Configurations from file
- Right-click the file in the Project pane
- Click “Run Mix ESpec”, which will both create the Run Configuration and Run it.
- If you want to only create the Run Configuration, select “Create Mix ESpec” instead
Alternatively, you can use keyboard shortcuts
- Select the directory in the Project pane.
Ctrl+Shift+R
will create the Run Configuration and Run it.
Finally, you can use the editor tabs
-
Right-click the editor tab for the test file you want to run
-
Click “Run Mix ESpec”, which will both create the Run Configuration and Run it.
- If you want to only create the Run Configuration, select “Create Mix ESpec” instead
Creating/Running mix espec
Run Configurations from line
If you want to be able to run a single test, you can create a Run Configuration for a line in that test
-
Right-click a line in the test file
-
Click “Run Mix ESpec”, which will both create the Run Configuration and Run it.
- If you want to only create the Run Configuration, select “Create Mix ESpec” instead
Alternatively, you can use keyboard shortcuts
- Place the cursor on the line you want to test
Ctrl+Shift+R
will create the Run Configuration and Run it.