Browsed by
Category: Testing

Enums and inheritance in .Net

Enums and inheritance in .Net

In one of my current projects I had the following code (I simplified the code a bit): public string ConnectionString { get { switch(this.Importer) { case Importer.SqlServer: return "Server=localhost;Database=Northwind"; case Importer.SqlServerOleDb: return"Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind"; default: throw new NotSupportedException( string.Format("Importer {0} is not supported yet.", this.Importer)); } } } After running the code coverage tool (dotCover from JetBrains) I received the following picture: First idea So, my code was clear and understandable, but obviously not fully tested (green: covered by tests,…

Read More Read More

Mocking frameworks in .Net

Mocking frameworks in .Net

A few month ago I played with some mocking frameworks in .Net. There are already some comparisons available (here, here or here). In this blog post I want to show which frameworks are available and which one fits best for agile development. You could download the source code from github.com. Software under Test (SUT) To demonstrate and evaluate all the different mocking framework I had to create a scenario where it is appropriate to use a mocking framework. So I…

Read More Read More

From NUnit to MSTest

From NUnit to MSTest

Last week I migrated several projects from NUnit to MSTest. The developers use the Developer version of Microsoft Visual Studio Team System, so they have integrated unit-test support for MSTest. In this post I show you all the problems and work I had to migrate the tests from NUnit to MSTest. Less assert-methods in MSTest In NUnit you have comparison assert methods, exception asserts, more type asserts, more utility asserts and so on (you see what I mean). There already…

Read More Read More

How to structure code in an unit test

How to structure code in an unit test

When you create your unit tests for a method in the SUT (software under test) you will ask yourself how to structure the code in the test method.I saw two kind of syntaxes which help to structure the code in a unit test method (well, actually there are at least three, but the third syntax is just chaos, so this is definitely not the way how to do it). SEVT-Syntax [code language=”csharp”] [TestFixture] public class ThingTest { [Test] public void…

Read More Read More

Code generation for unit testing

Code generation for unit testing

There exists a project at Microsoft which generate unit tests based of source code. The name of this interesting project is Pex.At the first time when I heard about this project I was skeptical. Where’s the value of generated tests? Doesn’t it break the “test first” approach? After I saw this screencast from the PDC 2008, I could find the answers for me:There is a value: It is often tedious to write all the unit tests with the extreme values…

Read More Read More