Monday, February 14, 2011

FakeItEasy breaking change for assertions

In the latest version of FakeItEasy (version 1.6.4062.205) there is a breaking change in how repeats are specified in assertions. The reason for this is that the old way – while logically correct – was not intuitive to a lot of people.

Before you could write “Repeated.Once” and that assertion would pass even though the method you were asserting on had been called twice. Now, logically this makes perfect sense, a call that has happened twice has happened once. The problem is that I’ve noticed that people doesn’t think that way and therefore assertions has been wrong.

The reason I hasn’t changed this before is that if I did change it it would be a breaking change and it would just change under the feet of people that had figured the behavior out and I was reluctant to make a breaking change that doesn’t break the build.

The solution I came up with is one that does break the build. You can no longer write “Repeated.Once”, you have to write “Repeated.Exactly.Once” or “Repeated.AtLeast.Once” or “Repeated.NoMoreThan.Once” or any other repeat twice, Times(4) and so forth.

Hopefully you agree with my decision that it was important to break the build in this case and I hope that it doesn’t cause too much frustration, it is actually a quite straight forward matter of find and replace.

3 comments:

  1. 'Repeated.Once' is correct for something that is done twice, because 'repeat' means 'do again'. I'm sad to see something perfectly correct being changed for numpties who can't speak English properly.

    ReplyDelete
  2. I agree Neil, however the new syntax makes sense too, the drawback is that it is a few extra characters. Most of the times however you would just use the MustHaveHappened()-overload where repeat is not expressed at all.

    ReplyDelete
  3. Nice post. I was checking constantly this blog and I’m impressed! Extremely useful info specially the last part I care for such information a lot. I was seeking this certain info for a long time. Thank you and good luck.breaking your furnace

    ReplyDelete