about unit test in android ppt,Unit test with Examples in.Net ppt

本文探讨了经典单元测试的定义,回顾早期Smalltalk中的实践,并强调编写可维护、可读性强的单元测试的重要性。作者分享了个人经历,揭示过度依赖脆弱测试导致的问题,提倡遵循最佳实践进行测试驱动开发。本书将引导读者从基础到高级,理解并应用在实际项目中编写、组织和维护高质量的单元测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

摘要:

12MEAP Edition Manning Early Access Program Copyright 2008 Manning Publications For more information on this and other Manning titles go to www.manning.com3Table of Contents Part 1 Getting started Chapter 1 The basics of unit testing Chapter 2 The first unit test Part 2 Core techniques Chapter 3 Using Stubs to break dependencies Chapter 4 Interaction testing using Mock Objects Chapter 5 Mock Object frameworks Part 3 The test code Chapter 6 Test hierarchies and organization Chapter 7 The pillars of good tests Part 4 Design and process Chapter 8 Integrating unit testing into the organization Chapter 9 Working with legacy code Appendices Appendix A Design and testability Appendix B Extra tools and frameworks 41 The basics of unit testing One of the biggest failed projects I worked on had unit tests. Or so I thought. I was leading a group of programmers to create a billing application, and we were doing it in a fully test-driven manner – writing the test, then writing the code, seeing the test fail, making the test pass, refactor, rinse, repeat. The first few months of the project were great; things were looking up, and we had tests that proved that our code worked. As time went by, requirements changed, and we were forced to change our code to fit those new requirements. Whenever we changed the code, tests broke and we had to fix them – the code was still working, but the tests we wrote were so brittle that any little change in our code broke them, even though the code was working just fine. It became a daunting task to change our code in a class or a method for fear of changing all the unit tests involved with that unit being tested. Worse yet, some tests became unusable because the people who wrote them had left the project and no one knew how to maintain the tests, or what they were testing. The names we gave our unit test methods were not clear enough. We had tests relying on other tests. We ended up throwing away most of the tests less than 6 months into the project. It was a miserable failure because we let the tests we wrote do more harm than good – they were taking too much time to maintain and understand than they were saving us in the long run. So we stopped using them. I moved on to other projects, where we did a better job writing our unit tests, and even had some great successes using them, saving huge amounts of debugging and integration time. Ever since that first project that failed, I've been compiling best practices for unit tests and using them on the next project. Every time I get involved in a new project, I find a few more best practices. A solid naming guideline is just one of those. Understanding how to write unit tests, and making them maintainable, readable and trust-worthy is what this book is about– no matter what language or Integrated Development Environment (IDE) you work with. This book will cover the basics of writing a unit test, then move on to the basics of Interaction testing, and from then we'll move to best practices for writing, managing and maintaining unit tests in the real world. 1.1 Unit testing - classic definition Unit testing in software development is not a new concept. It's been floating around since the early days of the programming language Smalltalk in the 1970s and proves itself time and time again as one of the best ways a developer can improve the quality of code while gaining a deeper understanding of the functional requirements of a class or method. Kent Beck is the person who introduced the concept of unit testing in Smalltalk. The concept he created has carried on into many programming languages today, which has made unit testing an extremely useful practice in software programming. Before we get too far, we need to define unit testing better. I will start with the classic definition most of us have heard a million times. 5UNIT TEST – THE CLASSIC DEFINITION 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.

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值