pragma solidity ^0.4.23;
contract adding{
uint256 public total;
function add(uint256 val1,uint256 val2) public returns(uint256){
total = val1+val2;
return total;
}
}
The above code add two numbers
var adding = artifacts .require("./adding.sol");
contract ('adding', function(accounts){
it ("it will add two numbers", function(){
return adding.deployed().then(function(i){
instance = i ;
return instance.add(3,4)
}).then(function(value){
assert.equal(value,7,"the values of 3 and 4 must be equal to 7" );
});
});
});
The above code is my unit test but the unit test fails. If I interact with my truffle console it will work
Contract: adding
1) it will add two numbers
> No events were emitted
0 passing (115ms)
1 failing
1) Contract: adding
it will add two numbers:
AssertionError: the values of 3 and 4 must be equal to 7: expected { Object (tx, receipt, ...) } to equal 7
I can see the following error in my console while running truffle test
value.toString()