Waffle smart contracts test reporting

Power up your Waffle tests for Ethereum smart contracts with Tesults reporting. This page explains how to get setup, it takes just a couple of minutes to start reporting results from Waffle. If you have any questions please reach out to the Tesults team.

If you are not using the Waffle test framework but are using JavaScript/Node.js view the Node.js docs instead for integrating with a lower-level library.

Installation

Tests in Waffle are written using Mocha.

Tesults provides a test reporter for Mocha and you can use it with Waffle. Install mocha-tesults-reporter:

npm install mocha-tesults-reporter --save

Configuration

Update the package.json file for your Waffle project to use the Tesults reporter for your test script:

package.json
module.exports = {
  ...
  "scripts": {
    "build": "waffle",
    "test": "NODE_ENV=test mocha --reporter mocha-tesults-reporter -- tesults-target=token"
    }
  }
  ...
}

The 'token' above should be replaced with your Tesults target token, which you received when creating a project or target, and can be regenerated from the configuration menu.

Then run your tests as usual:

npm test

Basic configuration complete

At this point Waffle will push results to Tesults after your tests complete. The target arg must be supplied as shown above otherwise reporting will be disabled.

Next steps

See the Tesults Mocha documentation for advanced configuration details. Whatever the mocha-tesults-reporter supports can be applied for use with Waffle including supplying build information and file uploads.

Result Interpretation

Result interpretation is supported by Waffle (using mocha-tesults-reporter). Install version 1.2.0 or newer. If you use result interpretation we recommend you add these minimum mapping values:

passed
pass
failed
fail

Go to the Configuration menu.

Configuration menu

Select Build Consolidation.

When executing multiple test runs in parallel or serially for the same build or release, results are submitted to Tesults separately and multiple test runs are generated on Tesults. This is because the default behavior on Tesults is to treat each results submission as a separate test run.

This behavior can be changed from the configuration menu.

Build Consolidation

Click 'Build Consolidation' from the Configuration menu to enable and disable consolidation for a project or by target.

When build consolidation is enabled multiple test runs submitted at different times, with the same build name, will be consolidated into a single test run by Tesults automatically.

This is useful for test frameworks that run batches of test cases in parallel. If you do not have a build name to use for consolidation, consider using a timestamp set at the time the test run starts.

Build Replacement

When build consolidation is enabled, an additional option, build replacement can optionally be enabled too. Just as with build consolidation, when multiple test runs are submitted with the same build name the results are consolidated, but with replacement enabled, if there are test cases with the same suite and name received multiple times, the last received test case replaces an existing test case with the same suite and name. This may be useful to enable in situations where test cases are re-run frequently and you do not want new test cases to be appended and instead want them to replace older test cases. This option is generally best left disabled, unless test cases are often re-run for the same build and you are only interested in the latest result for the run.

Dynamically created test cases

If you dynamically create test cases, such as test cases with variable values, we recommend that the test suite and test case names themselves be static. Provide the variable data information in the test case description or other custom fields but try to keep the test suite and test name static. If you change your test suite or test name on every test run you will not benefit from a range of features Tesults has to offer including test case failure assignment and historical results analysis. You need not make your tests any less dynamic, variable values can still be reported within test case details.

Proxy servers

Does your corporate/office network run behind a proxy server? Contact us and we will supply you with a custom API Library for this case. Without this results will fail to upload to Tesults.

Have questions or need help? Contact us