How to write a simple WP7 unit test using xUnitContrib?
I'm working from the XunitContrib codeplex page and toward the bottom it lists these steps
For Windows Phone 7 Follow along with this blog post Create a Windows Phone application Add references to:
- Microsoft.Silverlight.Testing.dll (Silverlight 3 version - included in release)
- xunit-silverlight-wp7
- xunit.extensions-silverlight-wp7
- xunitcontrib.runner.silverlight.toolkit-wp7
Visual Studio may display warnings about including Silverlight 3 assemblies. Ignore it, these are the right files
Add [Fact] based tests and run the app (note- the blog post mentioned isn't using fact based tests so I'm even more confused ...)
But after I add the above mentioned dll's and start with something like the below ... resharper and I can't seem to hookup the testing harness enough to compile. Has anyone actually wired up a un开发者_如何学Goit test with xunit for WP7?
public class MyFirstWp7Test
{
[Fact]
public void Can_Run_Test_For_WP7()
{
var x = "hello world";
Assert.Equal("hello world", x);
}
}
You can't use resharper to run Silverlight or Windows Phone tests, unfortunately. The xunitcontrib resharper runner is for the desktop clr only (newer builds ignore files in a silverlight/wp project so you don't even see the unit test marker in the editor).
You need to actually deploy to the device or emulator, run your application and drive the tests through the UI of the Silverlight Unit Testing Framework. You can filter by tag, test class or test method name, but it all has to be in the phone's environment.
I finally found a way to test-drive my app on the WP7 platform using NUnit and ReSharper.
I did a short screencast on my blog for a full "how-to" of sorts
http://toranbillups.com/blog/archive/2011/07/24/Test-Driving-My-Windows-Phone-7-App
精彩评论