hopa-core provides the structure for writing executable examples of how your code should behave, and an hopa command with tools to constrain which examples get run and tailor the output.
echo alias hopa='./hopa/hopa/hopa' >> ~/.bashrc
source ~/.bashrc
cd your_project
git clone git@github.com:HopaBDD/hopa.git
hopa init
Hopa uses the words "describe" and "it" so we can express concepts like a conversation:
"Describe a Modification"
"It must initialize correctly"
source("example_src/module_1.c")
{
#include "../example_src/module_1.h"
{
describe("Modification")
{
it("must initialize correctly")
{
ModuleOneInit();
ModuleOneGetState() to_eq(MOD_1_VAL);
}
}
}
}
before_each
block is called before each it
block, and is intended for repetitive actions.
{
before_each
{
printf("Hello\n");
}
it("...") {}
it("...") {}
it("...") {}
}
Result:
Hello
Hello
Hello
You can also declare nested groups using the describe
or context
words:
{
context("with no items")
{
it("behaves one way")
{
/*
...
*/
}
}
context("with one item")
{
it("behaves another way")
{
/*
...
*/
}
}
}
When you install the hopa-core , it installs the hopa
script, which you'll use to run hopa. The hopa
command comes with many useful options.
Run hopa --help
to see the complete list.