bulloak
A simple, fast, and easy to use Solidity test generator based on the Branching Tree Technique.
Installing
cargo install bulloak
Usage
Basic Usage
Say you have a foo.tree
file with the following contents:
foo.sol
└── when stuff called
└── it should revert
If you pass it to bulloak
like so, you will get the skeleton of a test contract printed to stdout
:
$ bulloak foo.tree
pragma solidity [VERSION];
contract FooTest {
modifier whenStuffCalled() {
_;
}
function testRevertsWhenStuffCalled()
external
whenStuffCalled
{
// it should revert
}
}
Scaffold Multiple Trees
If you are working in a solidity project and you have multiple trees you want to scaffold, you can use the -w
option.
$ bulloak -w ./**/*.tree
This will create solidity
files with the same name as the .tree
files with the result of scaffolding each tree.
Options
Usage: bulloak [OPTIONS] [FILES]...
Arguments:
[FILES]... .tree files to process
Options:
-c Whether to print `it` branches as comments in the output code
-i <INDENT> The indentation of the output code [default: 2]
-w, --write-files Whether to write to files instead of stdout
-h, --help Print help (see more with '--help')
-V, --version Print version
Compiler Errors
Another feature of bulloak
is reporting errors in your input trees.
For example, say you have a buggy foo.tree
file, which is missing a └
character. Running bulloak foo.tree
would report the error like this:
•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
bulloak error: unexpected `when` keyword
── when the id references a null stream
^^^^
--- (line 2, column 4) ---
file: foo.tree
Contributing
Please refer to CONTRIBUTING.md.
Inspired By
bulloak
is heavily inspired by BurntSushi's regex crate.
License
This project is licensed under either of:
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0).
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT).