btest is a language-agnostic testing framework.
Install D (either dmd or ldc) and dub (the D package manager):
brew install dmd dub
Install dep packages:
dub
Create a btest.yaml
file like so:
test_path: <path-to-test-directory>
runners:
- name: <runner-name>
run: <cmd-to-run-on-each-test-case>
Here is a filled-in example:
test_path: tests
runners:
- name: Run tests with cpython
run: python test.py
- name: Run tests with pyp
run: pypy test.py
Then create a tests directory and add a yaml file for each set of tests like so:
cases:
- name: <name-of-test-case>
status: <expected-exit-status>
stdout: <expected-stdout-output>
<test-case-key>: <test-case-value>
templates:
- <file-name>: <file-contents>
Here is a filled-in example:
cases:
- name: Should exit on divide by zero
status: 1
stdout: |
Traceback (most recent call last):
File "test.py", line 1, in <module>
4 / 0
ZeroDivisionError: division by zero
denominator: 0
templates:
- test.py: |
4 / {{ denominator }}
Run all tests:
$ btest
tests/divide-by-zero.yaml
[PASS] Should exit on divide by zero
1 of 1 tests passed for runner: Run tests with cpython
Run just a specific test file by name (assuming the test path root is tests/
,
this will run the tests in tests/divide-by-zero.yaml
):
$ btest -f divide-by-zero
tests/divide-by-zero.yaml
[PASS] Should exit on divide by zero
1 of 1 tests passed for runner: Run tests with cpython
Check out the btest.yml
file and tests
directory in: