Remix Project
Published in

Remix Project

Solidity Unit Tests via a GitHub Action

This GitHub action can run Solidity Unit Tests as part of your continuous integration and deployment process.

When coding a project, shifting the Solidity Unit Tests (SUT) to the GitHub side of things can optimize your workflow. Every time a push to the repo is made, the SUTs will run. Having Solidity Unit Tests run automatically on GitHub is one less thing to think about.

Adding Remix’s Solidity Unit Tests Action to your GitHub workflow is simple!

Check the GitHub Actions page for the Solidity Unit Tests Action.

  1. In your repo make a directory called .github/workflows
  2. In that directory, make a .yml file like the one below.
  3. In the example below, the action will look through the sample/tests directory, and will check for files named with a _test.sol suffix (e.g. filename_test.sol) and will run those tests.
  4. Change the name of the sample/tests directory to make it fit with your repo’s structure.
  5. If you don’t want to put a folder path, give the full path to a test file.
  6. Set the compiler version to be the same as the one in the contract files.
name: solidity-unit-testing-action
on: [push]

runs-on: ubuntu-latest
name: A job to run sample solidity tests
- name: Checkout
uses: actions/checkout@v2
- name: Run SUT Action
uses: EthereumRemix/sol-test@v1
test-path: 'sample/tests'
compiler-version: '0.8.15'

Learn to write Solidity Unit Tests

The one prerequisite to using this action is knowing how to write Solidity unit tests. Check our testing docs here. You can play with these tests right in Remix, either by activating the Solidity Unit Tests plugin in the Remix Plugin Manager, or just by clicking here. In addition, you can try out these tests locally using our NPM package.

As you can see, its easy to set up the GitHub Action, so try it out!

Please let us know what you think. Tweet us: @EthereumRemix or join us on Gitter or Discord.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store