开发者

Isolating dependencies in Silverlight unit tests

I'm in the process of writing an LOB application in Silverlight and I'm a little dismayed by all the roadblocks I'm hitting with unit testing.

  • PRISM uses a lot of extension methods, which are essentially static methods so not mockable.
  • All the mocking frameworks that use dirty tricks to mock non-virtual and static methods don't work in Silverlight (e.g. Moles, JustMock开发者_运维百科. Not sure about TypeMock Isolator.)

So, my question:

Is there a strategy for isolating dependencies in Silverlight unit tests?

Am I missing something, or just not thinking about this problem correctly? Can I use UI tests (such as those available in the new VS2010 Feature Pack 2) to work around this problem?

TIA


Have you looked at other MVVM frameworks then if you have such issues with Prism? Usually, all layers of a Silverlight application should be testable.

  • Models should be testable because they shouldn't have anything to do with any UI technology
  • View models should be testable because they shouldn't reference anything on the UI
  • Views (XAML) are declarative
  • You'll need to fill some gaps and write your own controls, attached properties and behaviors. You can look at the Silverlight Toolkit source code to see how they handle testing there.


you might check out silverunit (mentioned in second half of this video) Unit Testing in Silverlight with SilverUnit

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜