wpf 使用 MVVM 进行单元测试的好资源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11872250/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Good resources for Unit Testing with MVVM
提问by Darren Hale
I am reasonably new to WPF and MVVM but I understand the basics. The problem I am having is trying to find some good resources to learn unit testing with MVVM. I am new to unit testing.
我对 WPF 和 MVVM 相当陌生,但我了解基础知识。我遇到的问题是试图找到一些好的资源来学习使用 MVVM 进行单元测试。我是单元测试的新手。
Can anyone recommend some good resources whether it's blogs, videos, or even books.
任何人都可以推荐一些好的资源,无论是博客、视频还是书籍。
采纳答案by Jakub Kaleta
The topic has been widely discussed here:
这个话题在这里得到了广泛的讨论:
https://stackoverflow.com/questions/37359/what-c-sharp-mocking-framework-to-use
https://stackoverflow.com/questions/37359/what-c-sharp-mocking-framework-to-use
You can find plenty of similar questions in the Related questions list.
您可以在相关问题列表中找到大量类似的问题。
Arrange, Act Assert is helpful for structuring your unit tests for better readability. http://www.arrangeactassert.com/why-and-what-is-arrange-act-assert/
排列,Act Assert 有助于构建单元测试以获得更好的可读性。 http://www.arrangeactassert.com/why-and-what-is-arrange-act-assert/
You mentioned you are new to unit testing. I would suggest reading a few free ebooks discussing the topic in general, to get a good feel of unit testing. After all, unit tests are independent of the framework used in the project, because you should be testing individual classes, methods and not entire components.
您提到您是单元测试的新手。我建议阅读一些讨论该主题的免费电子书,以更好地了解单元测试。毕竟,单元测试独立于项目中使用的框架,因为您应该测试单个类、方法而不是整个组件。
Of course reading a good book is always worth it:
当然,读一本好书总是值得的:
MSDN Magazine has great articles about unit testing:
MSDN 杂志有很多关于单元测试的文章:
http://social.msdn.microsoft.com/Search/en-US?query=unit%20testing&Refinement=118&ac=8
http://social.msdn.microsoft.com/Search/en-US?query=unit%20testing&Refinement=118&ac=8
See: http://msdn.microsoft.com/en-us/magazine/dd419663.aspxfor an example MVVM application with unit tests.
请参阅:http: //msdn.microsoft.com/en-us/magazine/dd419663.aspx,了解带有单元测试的示例 MVVM 应用程序。
That should be enough to start.
这应该足以开始。
回答by cuongle
The Art of Unit Testingis good book for you. And Moqfor mocking framework

