楼主: Lisrelchen
1583 4

The Art of Unit Testing, Second Edition: with examples in C# [推广有奖]

  • 0关注
  • 62粉丝

VIP

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
49957 个
通用积分
79.5487
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币


  • The Art of Unit Testing, Second Edition: with examples in C#
  • By: Roy Osherove

  • Publisher: Manning Publications

  • Pub. Date: November 22, 2013

  • Print ISBN-10: 1-61729-089-0

  • Print ISBN-13: 978-1-61729-089-3

  • Pages in Print Edition: 296

  • Subscriber Rating: [4 Ratings]

  • 本帖隐藏的内容

    The Art of Unit Testing, 2nd Edition.pdf (13.4 MB, 需要: 10 个论坛币)





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Examples example Edition TESTING editio examples

本帖被以下文库推荐

沙发
Lisrelchen 发表于 2016-5-7 19:08:09 |只看作者 |坛友微信交流群
  1. Definition 1.0
  2. A unit test is a piece of a code (usually a method) that invokes another piece of code and checks the correctness of some assumptions afterward. If the assumptions turn out to be wrong, the unit test has failed. A unit is a method or function.
复制代码

使用道具

藤椅
Lisrelchen 发表于 2016-5-7 19:09:53 |只看作者 |坛友微信交流群
  1. Properties of a good unit test
  2. A unit test should have the following properties:

  3. It should be automated and repeatable.
  4. It should be easy to implement.
  5. It should be relevant tomorrow.
  6. Anyone should be able to run it at the push of a button.
  7. It should run quickly.
  8. It should be consistent in its results (it always returns the same result if you don’t change anything between runs).
  9. It should have full control of the unit under test.
  10. It should be fully isolated (runs independently of other tests).
  11. When it fails, it should be easy to detect what was expected and determine how to pinpoint the problem.
复制代码

使用道具

板凳
Lisrelchen 发表于 2016-5-7 19:11:24 |只看作者 |坛友微信交流群
  1. Listing 2.1. The LogAnalyzer filename-validation logic to test
  2. [Test] public void
  3. IsValidLogFileName_GoodExtensionLowercase_ReturnsTrue()
  4. {
  5.     LogAnalyzer analyzer = new LogAnalyzer();
  6.     bool result =         analyzer
  7.           .IsValidLogFileName("filewithgoodextension.slf");

  8.     Assert.True(result);
  9. }

  10. [Test]public void IsValidLogFileName_GoodExtensionUppercase_ReturnsTrue()
  11. {
  12.    LogAnalyzer analyzer = new LogAnalyzer();

  13.    bool result =
  14.        analyzer
  15.        .IsValidLogFileName("filewithgoodextension.SLF");

  16.    Assert.True(result);
  17. }
复制代码

使用道具

报纸
Lisrelchen 发表于 2016-5-7 19:13:57 |只看作者 |坛友微信交流群
  1. Listing 2.3. The LogAnalyzer filename-validation logic to test
  2. public class LogAnalyzer
  3.     {
  4.         public bool IsValidLogFileName(string fileName)
  5.         {
  6.             ...
  7.             if (string.IsNullOrEmpty(fileName))
  8.             {
  9.                 throw new ArgumentException(
  10.                     "filename has to be provided");
  11.             }
  12.             ...
  13.         }
  14.     }
复制代码

5.jpg (28.14 KB)

5.jpg

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-29 01:53