A new practitioner of TDD and unit tests has much to learn: how to what are acceptance tests? how to write tests that won’t break on every trivial change? what mock objects and why should you care? How do I test my product code? So if you’re looking for a place to learn all those … Continue reading Three Day TDD .NET Course (Israel)
Tag: NUnit
How to return default(Type) in runtime – a TDD example in four unit tests
I’ve found this question while going over my old StackOverflow answers:I'm using reflection to loop through a Type's properties and set certain types to their default. Now, I could do a switch on the type and set the default(Type) explicitly, but I'd rather do it in one line. Is there a programmatic equivalent of default?I … Continue reading How to return default(Type) in runtime – a TDD example in four unit tests
Find out where is the method that was called unexpectedly using fake objects
Every Isolation/Mocking framework out there can verify that a method of a fake object was called and not less important make sure that certain methods are not called. Let’s say that I want to make sure that a method didn’t encounter any errors during execution but verifying that logger.Error was not called: [TestFixture]public class MyClassTests{ … Continue reading Find out where is the method that was called unexpectedly using fake objects
How to run your unit tests as part of TFS build
Writing unit tests is good, having a build server that run the unit test on each commit/check-in is great! In the past I’ve used TeamCity and FinalBuilder to administer my builds and run my tests, it was easy and painless and it worked. Unfortunately we cannot always decide our organization build strategy and if … Continue reading How to run your unit tests as part of TFS build
When to use the SetUp attribute
I want to share with you a debate we had at work today: Which one of the following is a better test – this one? [TestFixture]public class MyClassTests{ private MyClass myClass; [SetUp] public void Initialize() { var arg1 = //... var arg2 = //... // More initialization logic myClass = new MyClass(arg, arg2); } [Test] … Continue reading When to use the SetUp attribute
How to collect NUnit test results in TeamCity
I’ve been using TeamCity for some time now and I love it - It’s easy to install and use. TeamCity can also run unit tests using several test frameworks and collects data about the tests runs as long as you’re using one of the supported build scripts (e.c. NAnt or MSBuild) – from how many … Continue reading How to collect NUnit test results in TeamCity
How to run NUnit tests created with VS2010 and .NET 4
Today when writing tests for a new project built using VS2010 I had an interesting problem: NUnit would not run my unit tests because the assembly that contained my unit tests was compiled using a newer version of the .NET runtime. There are several solutions to solve this issue from downgrading my project to use … Continue reading How to run NUnit tests created with VS2010 and .NET 4
#Nose – the unit test discovery tool
One of the benefits of programming in C#/VB.NET is amount of tools available - from Visual Studio to build servers to unit testing frameworks it seems that there is a tool for every job. I thought that my .NET tool belt has everything I need until recently, while learning Python (actually IronPython) I’ve discovered Python-Nose … Continue reading #Nose – the unit test discovery tool