NUnit for Silverlight updated: NUnit 2.5.5, Silverlight 4

Some while ago, I’ve ported NUnit to Silverlight; that post has been a follow-up to to Jeff Wilcox’s description of how to write unit tests instead of the standard MSTest syntax.

Here’s an update for the ported version of NUnit for version 2.5.5, and for both Silverlight 3 and Silverlight 4.

To create a Silverlight unit test project that uses NUnit, follow these steps:

  • Download and extract the binaries, or download the source code and build the assemblies on your computer
  • Create a new Silverlight unit test project using the Silverlight unit testing framework (and of course if you don’t have it installed, you should do that by now).
  • Reference the three assemblies from the NUnit for Silverlight project.
  • In the App.xaml.cs file, register the NUnit unit test metadata provider. This is done in the StartUp event handler for the application, before the test page is created:
    private void Application_Startup( object sender, StartupEventArgs e )
         new Microsoft.Silverlight.Testing.UnitTesting.Metadata.NUnit.NUnitProvider() );  
      RootVisual = UnitTestSystem.CreateTestPage();


  • 11-May-2010: Fixed a problem with the Silverlight 4 port; an assembly from the Silverlight 3 testing framework had been referenced.
  • 11-June-2010: Updated the NUnit port, please see NUnit for Silverlight: Now with data driven tests
  • 01-Dec-2010: Moved the project to Google code, updated to NUnit version 2.5.8.


Please download from nunit-silverlight on Google Code.


Christian is a software architect/developer. He lives in Germany, reads a lot, and likes cycling.

Tagged with: ,
Posted in Coding, Testing
14 comments on “NUnit for Silverlight updated: NUnit 2.5.5, Silverlight 4
  1. […] This post was mentioned on Twitter by Jason Hawgood, Rune Grimstad and Mithranvm, Jeremy Likness. Jeremy Likness said: Latest update of #Nunit for #Silverlight now available: […]

  2. Adrian says:

    Thanks for publishing this, it has really helped getting my project going with silverlight unit testing.

  3. […] Please find an updated version that supports SIlverlight 4 and NUnit 2.5.5 here. […]

  4. […] buttons to copy the selected test don’t work, but that’s probably easy to fix. My own humble unofficial port of NUnit to Silverlight does not work yet, but that will also be easy to fix – I think I’m going to have it out […]

  5. Carel Lotz says:

    Thanks for publishing. Can you for future updates please sign the assemblies as well?

  6. CarlzBad says:

    Is there a way to run these in nunit-console? I want to use this to run tests with ncover but am having some trouble figuring it out.

    • Christian says:

      Nope. The NUNit console does not support the Silverlight runtime. This project is only a port of the NUnit.Framework part that provides the test syntaxand assertions, nut the test runner. The tests still need to run under the MS Silverlight test runner. It is possible to collect covrage data, but you need Visual Studio 2010 Ultimate for that:

      • CarlzBad says:

        Thanks for the quick reply. I guess I am out of luck for now.

        Code coverage for Visual Studio 2010 got discontinued and stopped working in the RTM. I guess they were not kidding when they said it was experimental!

  7. Hugo Estrada says:

    Thanks so much for this port. It is going to help. I actually like the syntax of Nunit a lot, especially the newer constraint-based assertions; I believe that it makes the tests a lot more readable.

    Just one quick comment for other people who are trying to use this: after you follow your instructions, you set the testing project as the startup project, and then you hit f5.

  8. […] a version for Silverlight. But in order to use it, you'll need to change the App.xaml to use NUnit for the runner. Remember the Application_Start event? This is the initialization of the runner. […]

  9., c#,javascript…

    […]NUnit for Silverlight updated: NUnit 2.5.5, Silverlight 4 « greenicicle[…]…

  10. Artiom.K. says:

    Thank you very much, finally I can run my SL test without any error

  11. inormis says:

    Thank you so much. Finally I can run my test on TeamCity without any problem (at least for now). Good work.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: