The unit test provider for the Silverlight unit testing framework enables the unit testing framework to iterate and run xUnit.net 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?
- Each new instance of a test runs in a new instance of the test class
- IDisposable and IUseFixture<> are fully supported
- Tests can be defined with Fact, Theory or a custom attribute
- Skipping and all asserts are fully supported
- 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
- 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
- Timeout works as expected
What is different?
- 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
- 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)
- 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?
- The framework's Asynchronous attribute. Should work
- Bug and Tag attributes. Don't know if they work or not.
- Integration with AgUnit and StatLight. Don't think they will work
- 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.
- Look at UnitTestSystem.CreateDefaultSettings(); you can add multiple assemblies for one test runner assembly