Make sure you have truffle
and testrpc
installed
npm install -g truffle ethereumjs-testrpc
cd
into the repository directory and run the following command to create build artifacts for the smart contract:
truffle deploy
after that, you can run the tests using the following command:
truffle test
truffle create contract HelloWorld
pragma solidity ^0.4.4;
contract HelloWorld {
string message = "Hello World!!";
function HelloWorld() {
// constructor
}
function GetMessage() returns (string) {
return message;
}
}
truffle create test HelloWorld
const HelloWorld = artifacts.require('./HelloWorld.sol');
contract('HelloWorld:GetMessage', (accounts) => {
it('Should return a correct string', async () => {
const contract = await HelloWorld.deployed();
const result = await contract.GetMessage.call();
assert.isTrue(result === 'Hello World!!');
});
});