开发者

Are there any issues I should know about with unit test of Windows 7 Phone code?

I am assuming that as the code is standard C#, I can just use nUnit, TestDriven.net etc.

Have I missed something?开发者_如何学运维

What “traps” have other people hit trying to do this?


If you are talking about testing C# code in a Silverlight-based project, then there are some steps that need to be taken in order to use frameworks such as nUnit. The C# code in a Silverlight project will compile against the Silverlight framework binaries, so the binaries for nUnit won't work as-is since they are compiled against the standard .NET framework.

If you want to use nUnit, you can setup a regular C# class library and reference your Silverlight C# files into this project. You want to add them as a link, which is detailed here. From personal experience, this can get a little crazy because your file is linked in two places and the ability to link over the files are limited (if your Silverlight C# code references any Silverlight-specific binaries, you cannot perform this linking trick).

The other option is to use the Silverlight Unit Test Framework, the binaries for which can be found here. This works much like the Silverlight unit tester in the Silverlight Toolkit, except that it runs on the phone as a phone app.


Have you looked at the Silverlight Unit Testing Framework which is now part of the Silverlight Toolkit?

It's not been ported as part of the WP7 toolkit but some people have reported some success in using it anyway.


I would suggest WP7-CI. I have had success with it, and it's the only thing I could find so far that works with Asynchronous unit tests, if you'll ever need them.

See also my question:

Is there a wp7 mango unit test runner alternative to NUnit that supports the [Asynchronous] meta tag?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜