Universal, language-aware unit test runner.
Project description
universal-test-runner
The universal test runner is a zero-configuration, language-aware way to run your unit tests.
If you're working on a JS project, it runs [your package manager here] test
. You've run pytest
in this folder before? pytest
it is. Rust project? cargo test
coming right up. Is also clever about running all your go
module tests (regardless of how they're organized). No matter the command, all args are passed directly into the test runner.
Currently supports 7 languages (and their respective test frameworks). Please open an issue if I'm missing your favorite!
Installation
UTR is available on PyPi:
pipx install universal-test-runner
Design Philosophy
- The runner itself should need no configuration - it Just Works
- It should pass all arguments through to the underlying test command
- It should have wide language and test runner support; please open an issue if your use case isn't supported!
Usage
Once installed, the command t
will be available. Run that in a folder with tests and it'll do its best to run your unit tests:
% t
====================== test session starts ======================
platform darwin -- Python 3.11.0, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/david/projects/universal-test-runner
collected 37 items
tests/test_matchers.py ......................... [ 67%]
tests/test_runner.py ............ [100%]
====================== 37 passed in 0.04s =======================
It passes all arguments and environment modifications down to the chosen test runner.
If it can't guess the testing method, it will tell you so. Feel free to open an issue to request wider language support!
Debugging
The package also ships a program to surface info about itself: universal-test-runner
. It has a few key pieces of functionality:
- the
universal-test-runner --version
flag, which prints info about your installed package version - the
universal-test-runner debug
command, which prints info about which matcher would run (and why)
Supported Languages
- Python
- uses
pytest
if you've runpytest
before - looks for a
tests.py
file if not
- uses
- Rust
cargo test
- Go
- if there's a
X_test.go
, then runs a plaingo test
- if you pass any args at all, runs
go test your-args-here
- otherwise, runs
go test ./...
- if there's a
- Elixir
- runs
mix test
- runs
- Clojure
- runs
lein test
- runs
- Makefile
- looks for a line that starts with
test:
- looks for a line that starts with
- JS/TS
- if there's a
package.json
and it has atest
script, runs[package manager] test
, where[package manager]
is:npm
if there's apackage-lock.json
yarn
if there's ayarn.lock
pnpm
if there's apnpm-lock.yaml
- if there's a
Motivation
I work in a few languages at a time, so I've actually had a version of this in my dotfiles for a while. Also, as I've been doing Exercism's #12in23 program, I'm really switching languages. It's nice not to have to re-learn any muscle memory. Plus, increasingly complex bash
was holding me back.
Development
This section is people making changes to this package.
When in a virtual environment, run the following:
pip install -e '.[test]'
This installs the package in --edit
mode and makes its dependencies available. You can now run reddit-user-to-sqlite
to invoke the CLI.
Running Tests
In your virtual environment, a simple pytest
should run the unit test suite. You can also run pyright
for type checking.
Releasing New Versions
these notes are mostly for myself (or other contributors)
- ensure tests pass (
pytest
) - install release tooling (
pip install -e '.[release]'
) - build the package (
python -m build
) - upload the release (
python -m twine upload dist/*
)- give your username as
__token__
- give your password as your stored API key
- If you're getting invalid password, verify that
~/.pypirc
is empty
- give your username as
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file universal_test_runner-0.3.0.tar.gz
.
File metadata
- Download URL: universal_test_runner-0.3.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0d2d3ddd64db632c040e59e6c0ff0069eeacd0561af1468e2e2a33adad799ee |
|
MD5 | a64d93d087d0259a9164aed781cdf489 |
|
BLAKE2b-256 | 56fe2d0b22e2ea5321821a2ad7aa3fad14298c73b5d51c0d036573e715b2c920 |
File details
Details for the file universal_test_runner-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: universal_test_runner-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 264bdee0a0b48e8dd90ffc02e930963aede56c3c6f44451d33b5a424e16a27b7 |
|
MD5 | a43d77daa95507bf753d8141669ca9b5 |
|
BLAKE2b-256 | 9ca0ddec6b4b1fdefd11b69955dd9dd7f0104579c2c45c8a1c2e958844f6d519 |