Simple fuzzy test picker to run a unique test file or test block from the REPL instead of the whole testsuite.
TestPicker
is meant to be a wrapper tool around the existing standard Test.jl
library from Julia.
It does not require modifying your existing tests or use a different macro, however it expects that every test file you have under your test/
folder is self-contained!
That means you will need to import all the required packages for every test file, as well as any relevant test tooling.
For a best understanding see this small demo:
Run
] add TestPicker
Since it is a global tool, I would recommend installing in your global environment.
Simply running
using TestPicker
will load the new REPL mode into your session. You can add this line to your startup.jl
file.
To activate the mode press !
in a new line and you will get the following prompt:
test>
Input some fuzzy input to find the desired test file(s), e.g.:
test> subdirfile
which will get you a fuzzy search, press enter and the file will be run under the test environment.
[ Info: Executing test file /home/theo/.julia/dev/TestPicker/test/test-subdir/test-file-c.jl
Once executed, your original environment will be restored.
You can select multiple files to run in the fzf
selection with Tab
and Shift+Tab
.
If the character :
appears in your query, TestPicker
will instead look for all @testset
s present in your test
folder, including nested ones. Any preamble like using Test
, config = ...
will be run as well as long as it is before the @testset
block.
The syntax is the following
test> fuzzy-file-name:fuzzy-test-set-name
which will give you e.g. the following selection
"I am another testset | test-b.jl:6
"I am a testset" | test-a.jl:3
Similarly to the multiple files, you can select multiple testsets to be run and they will be run independently.
After running a collection of test files and/or testsets you can just repeat the same operation by calling -
(in the samme fashion as cd -
):
test> test-a
[ Info: Executing test file /home/theo/.julia/dev/TestPicker/test/sandbox/test-a.jl
Test Summary: | Pass Total Time
TestPicker - /home/theo/.julia/dev/TestPicker/test/sandbox/test-a.jl | 1 1 0.0s
test> -
[ Info: Executing test file /home/theo/.julia/dev/TestPicker/test/sandbox/test-a.jl
Test Summary: | Pass Total Time
TestPicker - /home/theo/.julia/dev/TestPicker/test/sandbox/test-a.jl | 1 1 0.0s
After running tests, the TestSet
summary is shown but you can inspect results further with ?
.
It will show a list of the tests that errored and failed with a preview of their stacktrace.
You can edit the selected test with Ctrl+e
or inspect the stacktrace for errored tests with Enter
.
It is also possible to inspect the stacktrace as a list with a preview of the source when possible and
Ctrl+e
edit the source of the current trace.
- All selections will be run inside a module, in a similar fashion to
SafeTestsets.jl
. - Before running any selection,
TestEnv.jl
activate()
is us to mimick thePkg.test()
behaviour. The original environment is restored afterwards, regardless of the outcome. - The evaluation will stop if an error happens outside of a testset.
Syntax highlighting is achieved by running bat
within fzf
, however
the signals needed to detect light/dark terminal background osc10/osc11 don't work in this case.
This means some characters may have too low contrast against the background to be readable.
The current workaround is to set a theme manually using the BAT_THEME
environment
variable e.g. add export BAT_THEME=GitHub
to your ~/.bashrc
- A great blog post on Julia REPL mechanics
- TestItemRunner.jl a package that work in vscode to run its own
@testitem
tests. - ReTest.jl a testing framework that also let you filter testsets.