我想为我的 Windows Phone 7 应用程序运行单元和集成测试。但是 jeff wilcox 提供的库和来自 http://smartypantscoding.com/a-cheat-sheet-for-unit-testing-silverlight-apps-on-windows-phone-7 通过模拟器运行。
但我想以与任何Windows应用程序运行相同的方式运行单独的测试,例如通过右键单击测试类中的单独测试..此外,如果有人想通过命令行运行测试而不调用sdk。
但目前可用的单元测试框架是通过模拟器运行的。
I want to run unit and integrated tests for my windows phone 7 application.But The library which has been provided by jeff wilcox and code from http://smartypantscoding.com/a-cheat-sheet-for-unit-testing-silverlight-apps-on-windows-phone-7 run through emulator.
But I want to run individual tests in the same way any windows application runs e.g by right clicking on individual tests in a test class .. also if soemone wants to run the tests through the command line without invoking the sdk.
But the unit testing framework which is currently available runs through emulator.
发布评论
评论(3)
通过良好的关注点分离和一些限制,您可以使用 Silverlight 运行时执行测试。配置完成后,您可以在 VS 和 AgUnit 或 TestDriven.net 运行测试http://statlight.codeplex.com/" rel="nofollow">Statlight 从命令行。
您可以在我写的博客文章上阅读有关设置说明的信息但为了保留有关 SO 的信息,我将在这里总结:
Reference Microsoft.Silverlight.Testing
和Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight
来自 Silverlight(不是 WP)工具包%programfiles%\Reference Assemblies\Microsoft\Framework\Silverlight\ v4.0\Profile\WindowsPhone71
并将Copy Local
设置为true
限制包括:
Microsoft.Phone.*
)如果您可以处理所有这些(我还没有决定是否值得),它可以提供相当快的速度测试周期,并且模拟器内测试仍然可以针对超出限制的任何内容运行。
我们真正需要的是支持快速、无头模式的模拟器(模拟器内测试的兼容性更高)和某种Gallio 适配器。
With some good separation of concerns and some limitations, you can execute your tests using the Silverlight runtime. Once this is configured you can run your tests using ReSharper+AgUnit or TestDriven.net in VS and Statlight from the commandline.
You can read about the setup instructions on a blog post I wrote up but for the sake of keeping information on SO, I'll summarise here:
Reference Microsoft.Silverlight.Testing
andMicrosoft.VisualStudio.QualityTools.UnitTesting.Silverlight
from the Silverlight (not WP) toolkit%programfiles%\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71
and setCopy Local
totrue
The limitations include:
Microsoft.Phone.*
)If you can deal with all that (I still haven't decided if it's worth it) it can provide a pretty quick test cycle, and the in-emulator tests can still be run for anything that sits outside the limitations.
What we really need is the emulator supporting a fast, headless mode (in-emulator tests is way more compatible) and some kind of Gallio adapter.
您必须通过模拟器运行单元测试。故事结束。
You'll have to run the unit tests through the emulator. End of story.
您可以在手机上运行 Silverlight 单元测试应用程序,但如果您有 WP7.5“Mango”,请确保 首先从 Jeff Wilcox 的博客获取 Mango 兼容的二进制文件。
要运行单个测试,请使用“测试标记”功能:在 TestClass 或 TestMethod 级别将标记添加到要运行
[Tag("MyTag")]
的测试。然后在测试应用程序启动屏幕上的文本框中输入匹配的标签。这是我发现的重新运行测试以快速验证您所获得的修复的最佳方法。我通常保留一个短标签用于调试(例如“e”),这样可以快速输入。
You can run the Silverlight Unit Test apps on your phone, but if you've got WP7.5 "Mango" make sure you get the Mango compatible binaries first from Jeff Wilcox's blog.
To run individual tests use the "test tag" capability: Add a tag to the tests you want to run
[Tag("MyTag")]
, either at the TestClass or TestMethod level. Then type the matching tag into the text box on the launch screen of the test app.That's the best way I've found of re-running tests to quickly validate a fix you've got. I usually keep a short tag reserved for debugging (e.g. "e") so it's quick to type.