Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (31 sloc) 2.2 KB

Unit Testing

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.

Now 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

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.

Run Tests

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.

Continuous integration

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

See also: example Su Squares contract and Travis build that uses remix-tests for continuous integration testing.

You can’t perform that action at this time.