Is there any way to auto-generate test-cases in Truffle?
As an example, the AutoFixture Library was helping me to auto-generate test-cases in xUnit. I'm looking for a similar functionality.
Is there any way to auto-generate test-cases in Truffle?
As an example, the AutoFixture Library was helping me to auto-generate test-cases in xUnit. I'm looking for a similar functionality.
Looking at Truffle's tests it seems like it uses mocha
for defining tests and chai
for checking that things are OK. This is a pretty common setup in JavaScript land. It might not even be mandated, but it's a good start.
This allows you to build tests like:
describe('My tests', () => {
for (const testCase of TEST_CASES) {
it(`also works for ${testCase.name}`, () => {
// check something about testCase
});
}
});
You can have arbitrarily many nestings of describe
, building a tree-structure of tests. With auto-generation via the language's own features (for loops, while loops etc) you get a very powerful way of getting a lot of tests at once.