Phone开发和单元测试

Phone开发和单元测试

本文介绍了Windows Phone开发和单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望启动一个针对Windows Phone的项目,但由于缺少单元测试支持,我对此感到有些失望.[p]

I'm looking to start a project targeting Windows Phone, but I'm slightly put off by the lack of unit testing support[1].

我习惯于使用NUnit/XUnit满足大多数测试需求,并使用诸如NSubstitute之类的东西进行模拟.据我所知,您不能将这些框架用于Windows Phone项目...

I'm used to using NUnit/ XUnit for most of my testing needs, with something like NSubstitute for mocking. Near as I can tell, you can't use these frameworks for Windows Phone projects...

经过一些调查,我想知道以下情况是否可行:

Given some investigation, I was wondering if the following scenario would work:

  • 使用Visual Studio 2012
  • 为视图模型和其他逻辑创建可移植类库项目
  • 为单元测试创​​建其他可移植类库项目
  • 等待Windows Phone 8 SDK [2],然后使用该视图创建视图.

通过使用可移植类库,我希望单元测试将尽可能接近在设备上运行,而不必破解模拟器.

By using a Portable Class Library, I'm hoping that the unit tests will be as close as possible to running on the device, without having to crack open the emulator.

另一个优点是,我可以看到该解决方案在TFS构建环境中有效-因此运行测试是CI构建的一部分...

Another plus point is that I can see that this solution working within a TFS build environment - so running the tests are part of a CI build...

我希望以此来衡量人们的看法,这是明智之举,还是愚蠢的事……

I was hoping to gauge peoples opinion on if this is a sensible move, or a fools errand...

谢谢,
Kieron

Thanks,
Kieron

[1]我知道有解决方案,但似乎没有像完整框架测试那样集成的解决方案-我是在专门谈论VS2012/Resharper中对支持单元测试的支持,而无需模拟器. >

[1] I know there are solutions out there, but none that seem as integrated as full framework testing - I'm talking specifically about support in VS2012/ Resharper for running unit tests without the need for an emulator.

[2]有人知道您是否可以使用WP8 SDK定位Windows Phone 7.x吗?

[2] Does anyone know if you can target Windows Phone 7.x using the WP8 SDK?

推荐答案

更新:现在支持Windows Phone 8的单元测试.

Update: Unit testing for Windows Phone 8 is supported now.

http://blogs.msdn.com/b/visualstudioalm/archive/2013/01/31/windows-phone-unit-tests-in-visual-studio-2012-update-2. aspx

这篇关于Windows Phone开发和单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:02