Click the double check icon to get to the “Solidity Unit Testing” plugin.
If you haven’t used this plugin before and are not seeing
double check icon, you have to activate it from Remix plugin manager.
Go to the plugin manager (by click the plug icon) and load up the unit testing plugin.
double check icon will appear on the left side icon bar. Clicking on icon will load the unit testing module in the side panel.
Generate Test File¶
Click the button
Generate test file to create a new solidity file in the current folder suffixed with
_test. This file contains the minimum you need for running unit testing.
Write tests to check the functionality of your contract. Remix injects a built-in
assert library which can be used for testing. Visit the library documentation here.
Apart from this, Remix allows usage of some special functions to make testing more structural. They are:
beforeEach()- Runs before each test
beforeAll()- Runs before all tests
afterEach()- Runs after each test
afterAll()- Runs after all tests
To get started, see this for sample implementation.
Click the button “Run tests” to executes all tests whose box has been checked below (by default all). The execution is run in a separate environment and the result is displayed below.
remix-tests is also a CLI, it can be used in a continuous integration environment which support node.js. Please find more information in the remix-tests repository