Run tests for multiple languages from Emacs.
This project attempts to create a user interface to run tests for different programming languages with a consistent user interface. There are commands common to all the supported programming languages and additional settings which are language specific.
So far there are modules for the following languages in connection with the indicated testing environments
- elisp – cask / ert
- python – pytest
- rust – cargo
- elixir – mix
- JavaScript / TypeScript – jest
- any other ... as soon as I need it or as soon as you implement it
Easiest way to install is from MELPA. If you have
configured the MELPA sources you can just install the test-cockpit
package using the package-install command.
You can of course also use straight.el. Put the following lines into your startup file.
(straight-use-package
'(test-cockpit-<language> :type git :host github :repo "johannes-mueller/test-cockpit.el"))where <langauge> is the programming language you need:
pythonfor python - pytestcaskfor elisp - cask / ertcargofor rust - cargoelixirfor elixir - mixnpm-jestfor JavaScript / TypeScript – jest
projectileas in MELPA to determine the project typetransientas in MELPA for the OO
But I am not using projectile!
That's fine. You only need to have it installed so that we can use it to guess the project type you are working on. We need that to know how to launch your unit test suite.
Language specific
- rust
emacs-toml
It is suggested that you bind the following two commands to keybindings that suit you best.
-
test-cockpit-repeat-testThis should be bound to a quickly reachable keybinding, that you can find easily and quickly. It tries to the last test that the current project has been tested with. If in the current session the project has not been tested yet, a dialog is opened for you to choose the way the testing should be performed.In either way, the test command that you give is remembered. Next time you hit your key binding, the exact same test command for the project is repeated.
-
test-cockpit-dispatchThis does open the test dialog for you to setup the test command. If the project type is not supported, it falls back toprojectile-test-command. So use this if you don't want to repeat the last test, but run a different one.
You can also use the following commands to run tests in a more manual way
test-cockpit-test-projectto run the whole test suite.test-cockpit-test-moduleruns only the tests of the current module.test-cockpit-test-functionruns only the test of the function at point.
If the current function at point or the current module cannot be determined, the last tested module resp. last tested function are tested. If there are no last tests, an error message is thrown.
There are two functions test-cockpit-add-custom-action and
test-cockpit-add-dynamic-custom-action that allow you to register custom
actions for a project type.
There are stubs to make use of the Dape package to call the recent test run in a Dape debugging session. So far, only the python backend supports this feature.
You can call this either using the transient UI or by the command
test-cockpit-dape-debug-repeat-test.
The development started more than a year ago in early 2021. Since then I have used it for my daily work and added new features every now and then. It turns out to work smoothly and to be quite useful.
- Test discovery
- Parsing test results to determine failed tests
- Generalizing it to a more comprehensive build-cockpit also doing simple builds and things like release uploads.
Check the issues for more short term goals.
Lots. I implement stuff as soon as I need it and have some time.
Ideas, issues, feature requests, PRs always welcome.