This project is read-only.
The unit test provider for the Silverlight unit testing framework enables the unit testing framework to iterate and run tests. It aims to be faithful to xunit by using the xunit SDK, however, there are a couple of interesting differences. Here are the important details:

What is supported?

  1. Each new instance of a test runs in a new instance of the test class
  2. IDisposable and IUseFixture<> are fully supported
  3. Tests can be defined with Fact, Theory or a custom attribute
  4. Skipping and all asserts are fully supported
  5. The framework's Owner, Description and Category metadata is supported in the form of traits using the same names (case-insensitive). Description is displayed in a tooltip on the UI. Owner gets output to the Visual Studio trace file (which doesn't appear to work in the April 2010 release). Category is not used by the framework
  6. The framework's Exclusive attribute is supported. This allows you to filter which methods should run. It should be applied to the methods and the class containing the methods
  7. Timeout works as expected

What is different?

  1. Unit tests are not run in a random order. By default, the unit test frameworks sorts tests alphabetically by test class. It should be possible to override this behaviour by passing a new instance of UnitTestSettings to UnitTestSystem, but this is untested
  2. Theory tests are supported by enumerating each parameterised test at STARTUP time, rather than at RUN time as on the desktop runners. This could affect startup performance if the data is retrieved via a lengthy process (e.g. web service, database, etc)
  3. Unit tests must be public methods. Silverlight doesn't support private reflection (think late binding - if it would compile, you can use reflection on it). You can make them internal, but only if you also grant InternalsVisibleTo on the appropriate version of the xunit-silverlight dll

What's not tested?

  1. The framework's Asynchronous attribute. Should work
  2. Bug and Tag attributes. Don't know if they work or not.
  3. Integration with AgUnit and StatLight. Don't think they will work

Top tips

  1. DO NOT FORGET to register the new provider. (UnitTestSystem.RegisterUnitTestProvider(new XunitContrib.Runner.Silverlight.Toolkit.UnitTestProvider());) If you don't - the framework won't find any tests.
  2. Look at UnitTestSystem.CreateDefaultSettings(); you can add multiple assemblies for one test runner assembly

Last edited Dec 14, 2010 at 11:51 PM by mattellis, version 5