Skip to content

rogeriochaves/unit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unit: Universal Test Generator

Build status

The most boring part of writing tests is having to setup the test runner for a new project, or having to learn how to write tests on a new language. People end up postponing it and end up never testing their code.

With unit, a simple unit path/to/file command will set up your test runner for many languages and test frameworks, and create a test file ready to run.

Instalation

For Mac, you can install using brew

brew tap rogeriochaves/tap
brew install unit

For Linux and Windows, download the binary on releases page

Usage example

$ unit src/user.rb
Test file created! Run it with `ruby test/test_user.rb`

You can also use other test runners

$ unit src/user.rb --rspec

Suported Languages

Language Test Runners
Clojure std
Elixir std
Elm elm-test
Java junit
JavaScript jest
Perl std, test-spec
Python std
Ruby std, rspec
Rust std, integration

The "std" test runner stands for the default test runner that comes with the language and requires no dependencies to be installed.

Contributing

If you'd like to support a new language or test framework, first create a new example project for it under tests/examples/mylanguage/mytestrunner. Then create or edit the test file for it on tests/mylanguage_test.rs.

You can follow the examples of other tests like tests/javascript_test.rs or tests/python_test.rs, and then run it with:

cargo test mylanguage

You will need to have rust installed to run cargo.

Then you can implement the generator, on src/generators/mylanguage.rs. Again, follow the examples of other modules, then add it to src/generators/mod.rs and src/lib.rs on the available_generators function.