Skip to main content

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

  1. The runner itself should need no configuration - it Just Works
  2. It should pass all arguments through to the underlying test command
  3. 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 =======================

If it can't guess the testing method, it will tell you so. Feel free to open an issue to request wider language support!

Supported Languages

  1. Python
    • uses pytest if you've run pytest before
    • looks for a tests.py file if not
  2. Rust
    • cargo test
  3. Go
    • if there's a X_test.go, then runs a plain go test
    • if you pass any args at all, runs go test your-args-here
    • otherwise, runs go test ./...
  4. Elixir
    • runs mix test
  5. Clojure
    • runs lein test
  6. Makefile
    • looks for a line that starts with test:
  7. JS/TS
    • if there's a package.json and it has a test script, runs [package manager] test, where [package manager] is:
      • npm if there's a package-lock.json
      • yarn if there's a yarn.lock
      • pnpm if there's a pnpm-lock.yaml

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)

  1. ensure tests pass (pytest)
  2. install release tooling (pip install -e '.[release]')
  3. build the package (python -m build)
  4. upload the release (python -m twine upload dist/*)
    1. give your username as __token__
    2. give your password as your stored API key
    3. If you're getting invalid password, verify that ~/.pypirc is empty

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

universal_test_runner-0.2.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

universal_test_runner-0.2.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file universal_test_runner-0.2.0.tar.gz.

File metadata

  • Download URL: universal_test_runner-0.2.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for universal_test_runner-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3d0bcdba949305bb0e6d31731d1daf8ab0cb32a9ac1a79473680de37627900bb
MD5 56d5cafde46c53741d26f7fa2d1fad3e
BLAKE2b-256 9e906f8595b6d524254df3227716a76960524d3c95e5a41f12a1c7cb004ad3c0

See more details on using hashes here.

File details

Details for the file universal_test_runner-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for universal_test_runner-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cb3828aaeeab871a092a8a01e84251144fe7c1b9381f138a72756bd1c4a6865
MD5 bb84361b92882fc7292a7ae44abbc53d
BLAKE2b-256 b6b4b115bf8543b13d44cfb311336922a815a9400e565bd710074c2c0db5d6f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page