Unitt
Unitt is a lean unit-test tool for the Arturo Programming language
At a Glance
Trying Unitt
Installation
arturo -p install unitt
Setup
Create a unitt.toml
file on your project root:
# unitt.toml - Configuration for unitt
path = "specs" # Path to Tests
suffix = ".spec.art" # Test file's suffix
binary = "./bin/arturo" # Arturo Binary
Running
unitt
Testing code
A real example of tests:
import {unitt}!
unix?: true
describe "binary appending" [
it "should operate integers" [
b: to :binary 0
expects.be: 'equal? @[express 2 append b 1]
expects.be: 'equal? @[express 1 b ++ 1]
]
it "should return a binary" [
b: to :binary 0
expects.be: 'binary? @[append b 1]
expects.be: 'binary? @[b ++ 1]
]
]
test.skip: unix? "split should deal with windows's paths" [
expects.be: 'equal? @[
["." "splited" "path"]
split.path ".\\splited\\path"
]
]
test "split should deal with unix path" [
expects.be: 'equal? @[
["." "splited" "path"]
split.path "./splited/path"
]
]
This will show you:
======== .unitt\example\example.spec.art ========
Describe: Module's Global Specs
⏩ split should deal with windows's paths
✅ split should deal with unix path
✅: equal? [. splited path] [. splited path]
Describe: binary appending
❌ - should operate integers
❌: equal? "2" 00 01
❌: equal? "1" 00 01
✅ - should return a binary
✅: binary? 00 01
✅: binary? 00 01
========== Summary ==========
⏏️ TOTAL: 5 assertions
✅ PASSED: 3 assertion
⏩ SKIPPED: 0 assertions
❌ FAILED: 2 assertion
========== ======= ==========
Documentation
Compatibility
Unitt supports both: XUnit and RSpec-like syntax:
- The 1st version was heavily influenced by XUnit.
- The 2nd one introduced a RSpec-inspired syntax alternatively, which is now the recommended one.
Rpec-ish API
describe: $[description :string tests :block]
:
Groups tests around some feature.it: $[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..skip :logical
:
Skips tests for some condition.
Will just skip if no condition is provided.
expects: $[condition :block]
:
A function that is only available inside theit
/test
case,
makes an assertion given thecondition
..to :literal
(or.be
)
Uses some function to evaluate the statement.
This helps to show the function name on display,
instead of atrue
/false
.
XUnit-ish API
test: $[description :string, testCase :block]
:
The same asit
..skip :logical
assert: $[condition :block]
:
The same asexpects
.with
The same as.to
and.be
suite: $[description :string tests :block]
:
The same asdescribe
.
Breaking Changes
There are some breaking changes from the latest major version, so make sure you've some time to change it before update.
- Script Runner: now, you don't need to setup a script runner anymore. Just delete it. Arturo's package manager has included the feature of script entries for packages, so you can run it such as a common CLI application out-of the box, such like pipx and npx.
test.prop
/it.prop
: I've added this for property-based tests, but honestly this does absolutely nothing. This attribute just replaces-
by a~
. Your test description should be semantic enough to know if this is use-case based or property based. This also reduces a lot the complexity of the library, making it less error-prone.assert.static
/expected.static
: This was added when I had no idea how well my evaluator would be. Now, I think this is mature enough to just don't use it at all. Static assertions are not that useful when debugging tests, either. If you need something similar, transform your expression into a:string
.fatal
: This was very useful since then, but the way our architecture works now, I think this is kind-of useless. In summary: If some test has an uncaught exception, this stops unitt and shows you the error. For failing tests, you can use the--clean
flag to show only failing specs.
Warning
Never import this lib as.lean
, or this will break the current code. This happens due to the nature of Arturo (being concatenative), and the way we importings are working right now. This may change in future.
Background photo on "At a Glance" by Luca Bravo on Unsplash
Last updated:
3.0.0 | 28 July 2025 | 2527625 / 37 files |
3.0.0-pre1 | 24 July 2025 | 2528095 / 38 files |
3.0.0-pre0 | 13 July 2025 | 2195482 / 43 files |
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.