Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight Unit Testing Framework running tests in external class library

I'm currently looking into different options for unit testing Silverlight applications. One of the frameworks available is the Silverlight Unit Test Framework from Microsoft (developed primary by Jeff Wilcox, http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/).

One of the scenarios I'm looking into is running the same tests on both Silverlight 3 (PC) and Windows Phone 7. The Silverlight Unit Test Framework (SLUT) runs on both PC and phone. To prevent having to copy or link files I would like to put my tests into a shared test library, that can be loaded by either a WP7 application using the SLUT, or a Silverlight 3 application using SLUT.

So my question is: will SLUT load unit tests defined in a referenced class library, or only in the executing assembly?

like image 965
Jonas Follesø Avatar asked Feb 27 '23 21:02

Jonas Follesø


1 Answers

I did some research, and turns out you can tell the SLUT test runner which assemblies to test. You do this by configuring the test settings when creating the test page.

private void Application_Startup(object sender, StartupEventArgs e)
{
    var setting = UnitTestSystem.CreateDefaultSettings();
    setting.TestAssemblies.Add(typeof(TestInReferencedAssembly).Assembly);            
    RootVisual = UnitTestSystem.CreateTestPage(setting);
}

In the code example above the TestInReferencedAssembly is a test defined in a class library referenced by the application running the SLUT test runner. You can add the assemblies the test runner should scan to find unit tests. In this case I add the assembly the TestInReferencedAssembly belongs to.

I have not tested if this functionality works when executing the SLUT on Windows Phone 7, but if it does we should be able to run the same test suite on Phone and Desktop.

like image 79
Jonas Follesø Avatar answered Apr 07 '23 21:04

Jonas Follesø