Unitt is a basic unit-test tool for the Arturo Programming language.
Unitt
Unitt is a basic unit-test tool for the Arturo Programming language
At a Glance
Trying Unitt
Unitt may be splited into two sections: the tester and the tests.
The tester is the section responsible to find, run and return error codes to the final user.
While the tests are responsible to group the rules and logic of the tests.
Initial setup
It's recomended that your runner be at the root of your directory, right before your tests folder.
All of your tests must begin with the test
prefix and end with the .art
extension to be found,
since you may want to mix them with some other files.
Being that said, that is the right way of setting up your tester:
Let's consider that you have the following directory:
src/
...
tests/
...
main.art
tester.art
Into your tester.art
, you must:
import {unitt}
do ::
runTests "tests"
To run it, call:
arturo tester.art
Tip
You may want to use a hashbang to don't need to call arturo for every run.
The tests itself
A real example of tests:
test "appending binaries with integer is working" [
b: to :binary 0
assert -> as.binary 2 = append b 1
assert -> as.binary 1 = b ++ 1
]
test.prop "appending binaries with integer returns a binary" [
b: to :binary 0
assert -> binary? append b 1
assert -> binary? b ++ 1
]
This will show you:
❌ - assert that appending binaries with integer is working
assertion : [as binary 1 = append b 1]
✅ - assert that appending binaries with integer is working
assertion : [as binary 1 = b ++ 1]
✅ ~ assert that appending binaries with integer returns a binary
assertion : [binary? append b 1]
✅ - assert that appending binaries with integer returns a binary
assertion : [binary? b ++ 1]
Note
Property-based tests have~
as separator.
Documentation
Runner
runTests: $[folder :string]
:
The runner function, this function will look for tests inside the relativefolder
.
Remember that all tests must begin with thetest
prefix, and be an.art
extension.
Tests
test: $[description :string, testCase :block]
:
The test case itself, you need to pass a clear description to it,
And the logic that you're trying to assert..prop
:
Indicates that a test is property-based.
assert: $[condition :block]
:
A function that is only available inside thetest
case,
makes an assertion given thecondition
.
Background photo on "At a Glance"
by Jack Anstey on Unsplash
2.0.1 | 17 February 2025 | 2089281 / 18 files |
1.1.2 | 27 March 2024 | 2924568 / 40 files |
1.0.0 | 17 February 2024 | 2924560 / 40 files |
0.2.0 | 17 February 2024 | 2819071 / 40 files |
0.1.4 | 3 February 2024 | 2810315 / 35 files |
0.1.3-pre | 31 January 2024 | 2801390 / 16 files |
0.1.2-pre | 29 January 2024 | 2798820 / 16 files |
No dependencies.