为 wp7 应用程序运行测试

发布于 2025-01-01 05:22:41 字数 415 浏览 0 评论 0 原文

我想为我的 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

神经大条 2025-01-08 05:22:41

通过良好的关注点分离和一些限制,您可以使用 Silverlight 运行时执行测试。配置完成后,您可以在 VS 和 AgUnit 或 TestDriven.net 运行测试http://statlight.codeplex.com/" rel="nofollow">Statlight 从命令行。

您可以在我写的博客文章上阅读有关设置说明的信息但为了保留有关 SO 的信息,我将在这里总结:

  • Reference Microsoft.Silverlight.TestingMicrosoft.VisualStudio.QualityTools.UnitTesting.Silverlight 来自 Silverlight(不是 WP)工具包
  • 参考程序集来自 %programfiles%\Reference Assemblies\Microsoft\Framework\Silverlight\ v4.0\Profile\WindowsPhone71 并将 Copy Local 设置为 true

限制包括:

  • 您测试的程序集无法引用手机特定的程序集或类型(例如 Microsoft.Phone.*
  • 一些共享 API 实际上是不同的

如果您可以处理所有这些(我还没有决定是否值得),它可以提供相当快的速度测试周期,并且模拟器内测试仍然可以针对超出限制的任何内容运行。

我们真正需要的是支持快速、无头模式的模拟器(模拟器内测试的兼容性更高)和某种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 and Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight from the Silverlight (not WP) toolkit
  • Reference assemblies from %programfiles%\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71 and set Copy Local to true

The limitations include:

  • Your tested assembly cannot reference phone specific assemblies or types (like Microsoft.Phone.*)
  • Some shared APIs are actually different

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.

一抹苦笑 2025-01-08 05:22:41

您必须通过模拟器运行单元测试。故事结束。

You'll have to run the unit tests through the emulator. End of story.

柳絮泡泡 2025-01-08 05:22:41

您可以在手机上运行 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文