drewbourne / mockolate

fake chocolate, mock objects and test spies for AS3
http://mockolate.org/
MIT License
146 stars 26 forks source link

VerifyingCouverture#never does not seem to work #65

Closed creynders closed 11 years ago

creynders commented 11 years ago

I've got the following code in a test:

[Test]
public function test_parsePlayerFromData_doesNotUpdateModelWhenReceivesNullish() : void{
    instance.parsePlayerFromData( null );
    verify( mockPlayersModel ).method( 'addPlayer' ).never();
}

And although the addPlayer method is never called I get the following error in the runner:

Expected : at least <1> invocations of addPlayer() 
but: PlayersModel
(mockPlayersModel).addPlayer() invoked 0/1 (-1) times
drewbourne commented 11 years ago

Apologies for the very late response. This is very true. That API could have been better. I recommend using the received() matcher instead:

[Test]
public function test_parsePlayerFromData_doesNotUpdateModelWhenReceivedNullish() : void {
    instance.parsePlayerFromData( null );
    assertThat( mockPlayersModel, received().method( 'addPlayer' ).never() );
}
creynders commented 11 years ago

Hey @drewbourne thanks for responding though, even if it was a little late :smile: I figured that one already out in the mean time though. Working on Robotlegs really made me appreciate mockolate. It rocks, although it's a bit opaque here and there.