Truffle: Events logs really interesting even when tests pass.

Created on 29 Jun 2016  Â·  6Comments  Â·  Source: trufflesuite/truffle

Truffle shows events shot by a contract when its test fail. That is really a cool feature that may be interesting even when tests successfully pass.

I personally use Events to understand better how my contract behaves while testing them. For instance:

event Test(uint testID);
​
function someFunction (address addr, uint _uint) returns (bool) {
        if (a)  { Test(111); return false;}
        if(b)) {Test(112); return false;}   
[...] }

// or 
    for (uint i=0; i<n; i++) {
            if (a(i)) {Test(i); return false;}
        }

I'm currently adding a assert.equal(1,2) at the end to have access to those events, but might be an interesting feature to have.

enhancement help wanted ready

All 6 comments

@HCharlanes Good feature. It'd likely need to be added via the console, i.e., truffle test --show-events, or something to that effect. Marking as enhancement and putting on the list of things to work on.

@p14n seems like that PR is in archived repository and was not merged in core. Do you have plans on submitting a new one here?

@gnidan when will this be released on the npm version of truffle?

This is in the beta, but not the full release. Closing this for issue maintenance. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coffee-converter picture coffee-converter  Â·  3Comments

rotcivegaf picture rotcivegaf  Â·  3Comments

timothywangdev picture timothywangdev  Â·  3Comments

ripper234 picture ripper234  Â·  4Comments

ferittuncer picture ferittuncer  Â·  3Comments