Silverlight 3 and NUnit Support?

May 31, 2010 at 1:12 PM
Edited May 31, 2010 at 1:17 PM


I'm quite excited about the add-in.  I'm about to look at the source code and want to know how difficult it would be to add SL 3 and NUnit support?  Any gotchas involved?



May 31, 2010 at 2:14 PM
Edited May 31, 2010 at 2:16 PM

For NUnit you would need to create a new TestProvider in the ReSharper plugin, just like the one for MSTest. And you would need to implement (or wrap) a test runner in the silverlight part, so that it notifies AgUnit of test results etc ...

Silverlight 3 support would require a different copy of the silverlight part of AgUnit (AgUnit.xap), that is targeted to silverlight 3 instead of silverlight 4. The common part of AgUnit would then need to be modified to start a different instance of the silverlight app for each test assembly, which I am planning to do in the next release already to improve test isolation ...

Let me know if you want to give it a shot, so that we avoid duplicate work ...

May 31, 2010 at 2:32 PM

The NUnit provider is not that important right now as we are actually using MSTest for running our Integration tests on the SL client.  We are only using NUnit for the unit tests on the SL client.  Wrt SL 3, I figured that part out and changed AgUnit to target SL 3.  However, I'm unable to get it running.  I did the following:

  1. Changed AgUnit to target SL 3 and recompiled
  2. Recompiled AgUnit.Runner.Common.  This embeds the SL 3 version of the AgUnit.xap.
  3. Recompiled AgUnit.Runner.Resharper50.  
  4. Copied the following assemblies to the C:\Program Files (x86)\JetBrains\ReSharper\v5.0\Bin\Plugins\AgUnit directory
    1. AgUnit.Runner.Common.dll
    2. AgUnit.Runner.Resharper50.dll
    3. Ionic.Zip.dll
  5. When I open our solution in VS 2010, the plugin is loaded and the R# Unit Test Explorer correctly picks up all our integration tests to execute.  However, when I execute it nothing happens.  I am supposed to see a web-browser popup that runs the tests using the SL test framework, right?  I tried running using all of the available options (Run | Debug | Debug Silverlight) but all seems to do nothing at this point in time.

I also tried debugging the whole setup following the steps in the readme.txt.  I got no exception but the aren't executing either.  What may I be missing?

Thanks for your time.

May 31, 2010 at 2:56 PM
Edited May 31, 2010 at 3:00 PM

What you can try is enable "Thrown" for CLR exceptions in Debug > Exceptions in Visual studio and hope you see the actual exception occurring.

All three parts of AgUnit require a different method of debugging:

- To debug AgUnit.xap (the silverlight part of the runner), use "Silverlight debug unit tests"
- To debug AgUnit.Runner.Common.dll (the .NET part of the runner/browser interop), use "Debug unit tests"
- To debug AgUnit.Runner.Resharper50.dll (the R# add-in), follow the steps described in README.txt (debugging visual studio itself)

What I usually also do is include the "AgUnit" and "AgUnit.Runner.Common" projects in the same solution as my test project, that way you can debug everything.

I guess the problem lies in the Silverlight part.

Jun 13, 2010 at 9:57 PM

I've been playing around with your most recent code and have been running SL3 test in VS2008. Great work! When do you expect to release the Silverlight 3 bits? Is there anything specific missing?



Jun 14, 2010 at 6:05 AM

Yes, what AgUnit does is build a .xap file that contains the AgUnit assemblies and the assemblies that will be tested. At this moment, the AgUnit assemblies (and the manifest of the .xap) target Silverlight 4.
I have already ported the AgUnit  assemblies to Silverlight 3 (as you can see there are two AgUnit.Silverlight projects now).

But the problem lies in the code that builds the .xap file, it still always uses the Silverlight 4 assemblies. That way if you run Silverlight 3 tests, they will still run under (and require) the Silverlight 4 runtime without quirks mode ...

What should happen now is that each assembly should be run in its own Silverlight host, targeting the correct framework version. Once that is done, I will create a 0.2 release.

Aug 2, 2010 at 7:42 AM

Hi Sean

Any update on an official release that supports VS 2010 and SL3?

Aug 2, 2010 at 8:22 AM

Hi Carel

I will try to make work of it asap, there is only one final part missing: a silverlight 3 project still requires the runtime for silverlight 4 (which most users should have by now).

The current source code already supports SL3 and VS2008, so you can try that out already.