如何在csharp中编写单元测试代码 [英] How do I code unit testing in csharp
本文介绍了如何在csharp中编写单元测试代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习单元测试并且正在为项目https://github.com/alialavia/MSINet请求一个示例c#代码,它将指导我做什么。
我尝试了什么:
stilll无法确定哪些方法包含在测试中以及哪些方法可以省略。
I am learning unit testing and was requesting a sample c# code for the project https://github.com/alialavia/MSINet which will guide me on what to do.
What I have tried:
stilll can't determine which methods to include in test and which to leave out.
推荐答案
您是否已经看过主机测试框架的教程?
例如
MSDN:演练:为托管代码创建和运行单元测试 [ ^ ]
MSDN:单元测试基础知识 [ ^ ]
CodeProject:科瑞单元测试你的c#代码 [ ^ ]
NUnit - 快速入门 [ ^ ]
从现有的学习资料开始,可能比选择一个随机项目更明智,因为据说,它不是真正可测试的。
Have you already watched tutorials on main unit testing frameworks?
For example
MSDN: Walkthrough: Creating and Running Unit Tests for Managed Code[^]
MSDN: Unit Test Basics[^]
CodeProject: Creating Unit tests for your c# code[^]
NUnit - QuickStart[^]
It may be wiser to start from the beginning with existing learning material than to pick up a random project which, as it has been said, is not really testable.
>
该项目中没有一种方法可以在任何实际意义上进行单元测试。需要重写整个项目以适应测试。
There isn't a single method in that project that is unit testable in any practical sense. The entire project would need to be rewritten to accommodate testing.
这篇关于如何在csharp中编写单元测试代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文