Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 220 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
220
Dung lượng
1,5 MB
Nội dung
[...]... asked, or try an experiment live on a computer before continuing Language-specific Versions As of this printing, PragmaticUnitTesting is available in two programming language-specific versions: • in Java with JUnit • in C# withNUnit Acknowledgments from the First Edition We’d especially like to thank the following Practitioners for their valuable input, suggestions, and stories: Mitch Amiano, Nascif Abousalh-Neto,... use testing effectively in your project in Chapter 8 This chapter also discusses how to handle existing projects with legacy code We’ll then talk about how testing can in uence your application’s design (for the better) in Chapter 9, Design Issues We then wrap up with an overview of GUI testingin 10 The appendices contain additional useful information: a look at common unittesting problems, extending... perhaps much more formal testing depending on your environment But testing, as with charity, begins at home 1.3 Why Should I Bother withUnit Testing? Unittesting will make your life easier.3 Please say that with us, out loud Unittesting will make your life easier That’s why we’re here It will make your designs better and drastically reduce the amount of time you spend debugging We like to write code,... experience withunittesting But while the examples are in C#, using the NUnit framework, the concepts remain the same whether you are writing in C++, Fortran, Ruby, Smalltalk, or VisualBasic Testing frameworks similar to NUnit exist for over 60 different languages; these various frameworks can be downloaded for free.2 1 http://www.pragmaticprogrammer.com/titles/utc2 2 http://www.xprogramming.com/software.htm... project and personal success Unittesting is a relatively inexpensive, easy way to produce better code, faster Unittesting is the practice of using small bits of code to exercise the code you’ve written In this book, we’ll be using the NUnittesting framework to help manage and run these little bits of code Many organizations have grand intentions when it comes to testing, but tend to test only toward... has done unittesting before, we hope there will be a couple of nice surprises for you here Skim over the basics of using NUnit and concentrate on how to think about tests, how testing affects design, and how to handle certain team-wide issues you may be having And remember that this book is just the beginning It may be your first book on unit testing, but we hope it won’t be your last Where To Find The... approach Which brings us to unittesting As we’ll see, unittesting is important to you as a programmer because it provides the feedback you need Without unit testing, you may as well be writing programs on a yellow legal pad and hoping for the best when they’re run That’s not very pragmatic This book can help It is aimed primarily at the C# programmer who has some experience writing and designing code, but... supposed to do • Unit tests are not maintained: tests are ignored (or deleted) forever if they start failing, or no new unit tests are added, even when bugs are encountered that illustrate holes in the coverage of the unit tests If you find any of these symptoms, then your team is not unittesting effectively or optimally Have everyone read up on unit 14 R OADMAP testing again, go to some training, or try... remains open as to whether that’s the right thing to do according to the customer or end-user: that’s what acceptance testing is for We’re not really concerned with formal 1 Because Dale had been integrating all along via the unit tests 3 W HY S HOULD I B OTHER WITH U NIT T ESTING ? validation and verification or correctness just yet We’re really not even interested in performance testing at this point... at common unittesting problems, extending NUnit itself, a note on installing NUnit, and a list of resources including the bibliography We finish off with a summary card containing highlights of the book’s tips and suggestions So sit back, relax, and welcome to the world of better coding 15 Chapter 2 Your First Unit Tests As we said in the introduction, a unit test is just a piece of code It’s a piece . www.XProgrammin g.com
Pragmatic Unit Testing
in C# with NUnit, Second Edition
Andy Hunt
Dave Thomas
with Matt Hargett
The Pragmatic Bookshelf
Raleigh, North Carolina. more
formal testing depending on your environment. But testing,
as with charity, begins at home.
1.3 Why Should I Bother with Unit Tes ting?
Unit testing will