Skip to main content
Fix grammar and spelling
Source Link
Ismael
  • 30.3k
  • 23
  • 54
  • 97

Unit test is going wrongin truffle fails

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 doesadd two numbers adding

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" );
    });
  });
});

THeThe above code is my unit test but the unit test is being failed fails.I intracted If I interact with my truffle console it worked fine plese help mewill 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

iI can see the following error in my console while running truffle test

Unit test is going wrong

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 does two numbers adding

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 is being failed .I intracted with my truffle console it worked fine plese help me

  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

Unit test in truffle fails

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

Source Link

Unit test is going wrong

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 does two numbers adding

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 is being failed .I intracted with my truffle console it worked fine plese help me

  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