You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have marked a method to fail. And need to assert the fact in test that that method was never called.
In this particular case, the mock throws an error, but the SUT catches it, since its running a loop, with try/catch in the loop.
Thus my tests are all passing. :(
Ideally if assertThrows would throw an exception when any method was called on mock that was marked for failure, this wouldn't let my test pass.
Is it possible to easily integrate this feature?
thanks.
this.assert=function(){varsuccess=true;for(varmethodinentries){varentriesForMethod=entries[method];entriesForMethod.forEach(function(entry){if(!entry.shouldFail&&entry.executed==false){success=false;console.error("method call for: '"+method+"()' with params: "+getParamString(entry.args)+" was not executed!\n");}if(entry.shouldFail&&entry.executed){success=false;console.error("method call for: '"+method+"()' with params: "+getParamString(entry.args)+" should not be executed!\n");}});}returnsuccess;};
The text was updated successfully, but these errors were encountered:
In other mocking frameworks, the fail method would have a name like raiseError or throws. The assertThrows is a method that raises an Error when asserting that the test has met the expectations of the mock unlike the assert method that just writes stuff to console.error. We will fix this confusion, I think, in the next major release.
From Feature: assertThrows should not succeed when a "marked to fail" method was called on mock (Issue #14) from @jigargosar:
I really am missing this feature.
I have marked a method to fail. And need to assert the fact in test that that method was never called.
In this particular case, the mock throws an error, but the SUT catches it, since its running a loop, with try/catch in the loop.
Thus my tests are all passing. :(
Ideally if assertThrows would throw an exception when any method was called on mock that was marked for failure, this wouldn't let my test pass.
Is it possible to easily integrate this feature?
thanks.
The text was updated successfully, but these errors were encountered: