ETHcode update v0.0.6 — Unit testing solidity with remix-tests

0mkar
0mkar
Oct 30 · 2 min read

Solidity TDD focused development update. Compile solidity and run unit tests using remix-tests framework.

Install ETHcode from Visual Studio Marketplace. ctrl+alt+e activates the plugin. Press ctrl+alt+c to compile and ctrl+alt+t to run unit tests using ETHcode. Test file names should be like <filename>_test.sol.


SafeMath unit testing

We used safeMath library from OpenZeppelin to perform some unit testing on uint types. More details on safeMath library github.

Import and use safeMath library for arithmetic operations on uint types.

Now all uinttypes will be using SafeMath library.

safeMath Tests

String types unit testing using string utils

We used stringUtils library to perform some unit testing on string types. More details on stringUtils library on github.

First import and use stringUtils for string types.

We will use stringToUint, stringCompare, stringLen, stringConcat functions from stringUtils library for performing various operations on string types.

stringUtils Tests

Bit operators unit testing

We used bits library from ethereum/solidity-examples to perform some unit testing on bits types. More details on bits library on github.

Import & use bits library.

Then our bits types unit tests are as follows

Bits Tests

Full source can be found on our github repo — https://github.com/quantanet/solidity-examples/tree/master/UnitTesting

Ethcode gitter support channel —https://gitter.im/Ethereum-Devtools-Developers-Studio/ethcode

Help Quanta Network by donating Ethereum — 0xd22fE4aEFed0A984B1165dc24095728EE7005a36

Quanta Network

Ethereum Devtools Developers’ Dungeon

0mkar

Written by

0mkar

Quanta Network

Ethereum Devtools Developers’ Dungeon

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade