Anyone who ever googled (binged?) about unit testing have heard about the “one assert per test rule”. The idea is that every unit test should have only one reason to fail. It’s a good rule that help me write good, robust unit test – but like all such rules-of-the-thumb it’s not always right (just most … Continue reading Comparing Two objects using Assert.AreEqual()
Tag: FakeItEasy
Using NUnit and FakeItEasy to create fake objects automatically for your tests
From time to time I get to teach and mentor Java developers on the fine art of unit testing. There are many similarities when unit testing in Java and .NET but more interesting are the differences between the two. Faking objects in Java using MockitoOne of the well-used Java Isolation (Mocking) frameworks is called Mockito … Continue reading Using NUnit and FakeItEasy to create fake objects automatically for your tests
What to do when FakeItEasy throws System.BadImageException
Today I had a weird problem at work. I’ve been working with a new team and they’ve been writing unit tests using FakeItEasy when they got a strange error message:System.BadImageFormatException: … The signature is incorrect.Now I’ve been using FakeItEasy for some time and I never once saw this strange behavior. Googling for the problem only … Continue reading What to do when FakeItEasy throws System.BadImageException
On object creation and unit tests
There is always a balance between readability and maintainability when writing unit tests.I hate hearing a fellow developer say – “the task took me X time more because I had to fix 100+ tests because I refactored my production code”. This means I’m always on the look for ways to decrease the tests maintenance overhead.While … Continue reading On object creation and unit tests
How to write a unit test
Last week I had the pleasure of participating in Sela Developer Practice. Before my session I sat through Gil ZIlberfeld’s session “7 steps for writing your first unit test” and I found myself thinking – what are steps I take when writing a new unit test?I’ve been writing them for so long and never noticed … Continue reading How to write a unit test