Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight 5 Unit testing in Visual Studio 2012

The 'Silverlight Unit Test Application' project type is missing from within Visual Studio 2012. I can see it in VS 2010, but not in VS2012. I have installed and re-installed the Silverlight 5 toolkit from codeplex. Creating and running a silverlight unit test project in VS2010 works, but when running the tests through R# in VS2012, I get "Inconclusive: Test wasn't run"

Any help / suggestions would be greatly appreciated.

like image 285
user2115298 Avatar asked Feb 27 '13 12:02

user2115298


2 Answers

This link has the answer that worked for me:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/5e991b0d-8061-4c4e-a17d-82b4abd58d6c/vs-2012-silverlight-unittest

I recommend starting a new Silverlight project and installing the SilverlightToolkit-Testing NuGet package. In your test files, put in usings for Microsoft.Silverlight.Testing and Microsoft.VisualStudio.TestTools.UnitTesting and use regular [TestClass] and [TestMethod] attributes. To run them, you can use the Toolkit test runner by putting RootVisual = UnitTestSystem.CreateTestPage(); in your App.Application_Startup(), use Silverlight Unit Test Adapter (which currently is at v0.0.1 and doesn't really work), or (the best approach by far) install ReSharper and the AgUnit plugin.

like image 127
Keith Payne Avatar answered Oct 14 '22 18:10

Keith Payne


It's possible to reference Silverlight libraries from ordinary .NET libraries. So, if you are going to unit test only your view models, you can move them to a separate project, create an ordinary (not Silverlight specific) unit testing project and add a reference to the project of view models.

like image 24
Narek Malkhasyan Avatar answered Oct 14 '22 18:10

Narek Malkhasyan