Archive for the ‘Unit Tests’ Category

Specifying Custom NUnit Runner in MonoDevelop


I just discovered that the NUnit Add-In in MonoDevelop has a nice although undocumented feature: you can specify a custom test runner in the .csproj file, either as an executable or as a type. If you have the NUnit.Runners nuget package installed in your solution/project and you want MonoDevelop to run the unit tests with nunit-console.exe instead of the built-in runner, you can add the following to your .csproj file:


Now when you run your unit tests in MonoDevelop they will be run by nunit-console. This is useful when your unit tests make use of features that the NUnit Add-in doesn’t support yet, like ActionAttributes.

The other tags that are supported are:

  • TestRunnerArgs: Allows to specify additional command line arguments to the TestRunnerCommand
  • TestRunnerType and TestRunnerAssembly: allow to specify a test runner class/type and the assembly where to find this type.

If both TestRunnerArgs and TestRunnerType are specified, TestRunnerArgs takes precedence.

Strong-name Unsigned Nothings


A while back I wrote about how to access internal methods in unit tests. When I actually tried to do it, I got the following error message:

error CS1726: Friend assembly reference 'MyDllTests' is invalid. Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations. (more…)

Accessing Internal Methods in Unit Tests


In our code we often have the case where we want to test a method or property that shouldn’t be visible outside of the implementing assembly. In our build system our tests reside in separate assemblies (so that they don’t clog the production code) – which means we can’t access any methods or properties that aren’t public (more…)

NUnit hangs with SQLNCLI


The last couple of days I was hunting an interesting bug (FWC-16). During our build process we’re running automated unit tests with NUnit. This usually works pretty nice – until suddenly one of my co-workers got trouble. The build process just hang while running one particular test fixture. No crash, no errors, it just never finished. (more…)