The Art of Unit Testing: with Examples in .NET (Anglais) Broché – 11 juin 2009
Les clients ayant acheté cet article ont également acheté
Quels sont les autres articles que les clients achètent après avoir regardé cet article?
Description du produit
Présentation de l'éditeur
Heres what Michael Feathers, an Agile rock star in his own right, has to say
about The Art of Unit Testing : This is the best all around introduction to unit
testing on the market today.
The Art of Unit Testing guides the reader on the journey from beginner to master
in the subtle art of unit testing. Based on expert author Roy Osheroves
real-world development experiences, this book shows developers how to make
sure the code that they write actually works as expected, and how to make these
verifications as automated as possible. Not only that, the book shows techniques
that help to make sure that tests are maintainable, readable, and test the right
thing over time.
The author establishes five rules for good unit tests built upon the three major
principles that any good test be maintainable, trustworthy, and readable. Clear
sections present established best practices, and the book also provides clear guidance
on what to test and where to start testing in a legacy code project.
Unlike other books on this topic, this book trades theory for real-world examples.
Its designed so that a working developer can start writing better unit tests
now. Unlike most Unit Testing and TDD books, most examples are in C#
on the .NET platform.
Introduction to unit testing and the basics of writing real-world unit tests
Best practices for writing maintainable, trustworthy, readable tests
Author Roy Osherove is highly visible and extremely well-known in this field
Agile principles like unit testing have found their way more slowly into the
Microsoft community than they have in Java. This book presents the well-honed
practices common in the Java world using examples in C#.
Biographie de l'auteur
For over a decade,
Roy Osherove has been a developer, lead, manager, and architect.
Roy speaks at international conferences such as TechEd, DevTeach, JAOO,
and DevDays about subjects relating to Agile development, unit testing and testdriven
development. Hes the founder of the Agile Israel User group and consults
and trains teams around the world.
Aucun appareil Kindle n'est requis. Téléchargez l'une des applis Kindle gratuites et commencez à lire les livres Kindle sur votre smartphone, tablette ou ordinateur.
Pour obtenir l'appli gratuite, saisissez votre numéro de téléphone mobile.
Détails sur le produit
Si vous vendez ce produit, souhaitez-vous suggérer des mises à jour par l'intermédiaire du support vendeur ?
Commentaires en ligne
Commentaires client les plus utiles sur Amazon.com (beta) (Peut contenir des commentaires issus du programme Early Reviewer Rewards)
Chapter 1 #available online at [...] is a brief but helpful introduction to unit testing and TDD #Test Driven Development#. I'd recommend it for anyone who is new to these subjects.
Chapters 2-5 teach how to use test and mock frameworks. They are .NET specific in the sense that the author uses NUnit and Rhino Mocks, but the definitions and descriptions in those chapters are applicable to other frameworks as well. I haven't tried it, but I suspect that the code could be put in C++ classes and run under Google Mocks & Test without many changes.
Chapters 6-7 are the heart of this book. They teeach how to write good tests and how to organize them. If you're already doing TDD, you could skip the rest of the book and just read these two chapters. They're worth the price of admission.
The last two chapters discuss how to introduce TDD to an organization and how to deal with legacy code. Osherove is a consultant, so he has had plenty of experience with introducing TDD. His suggestion to bring in a consultant is a bit self-serving, but has some merit. The legacy code chapter is mostly an overview of Feathers' book, but a good one.
Roy Osherove has a lot of experience helping companies with "the art" of unit testing. He believes the key to successful unit testing rests on three pillars: maintainability, readability, and trustworthiness. He explains in the book what those things actually look like in real-world examples and why you might not be getting everything you could be out of your tests if you overlook one of those.
Roy also includes a fairly detailed comparison of the latest tools and frameworks you have to choose from. This section alone could save a ton of research time by getting a fairly unbiased, expert's view of the pros and cons for these types of tools and frameworks:
- Test Frameworks: NUnit, MSTest, MbUnit, Gallio, xUnit, Pex
- Isolation Frameworks: Moq, Rhino Mocks, Typemock Isolator, NMock, NUnit.Mocks
- IoC Containers: StructureMap, Unity, Castle Windsor, Autofac, Common Service Locator (CSL), Spring.NET, Managed Extensibility Framework (MEF), Ninject
- Web Testing: Ivonna, VS Team System Web Test, NUnitAsp, Watir, WatiN, Selenium
- UI Testing: NUnitForms, Project White, Team System UI Tests
- Thread-Related Testing: Typemock Racer, Microsoft CHESS
- Acceptance Testing: FitNesse, StoryTeller
This book was a short 320 pages, but there is a ton of practical and applicable tips jammed between the covers. But, I have to mention that this book isn't as polished as you would probably expect with most published works. It isn't anything major, but just a few things in the text or code samples that should have been caught by testers or an editor. These issues don't really take away from the content, but it just wasn't up to the standard I expect when buying a published work. (And that is possibly the worst cover I have ever seen ... yes, I get the reference to "The Art of War").
If you are remotely interested in this topic, you should listen to a recent podcast Roy did with Scott Hanselman on "The Art of Unit Testing." Although the podcast is kind of like a cliff-notes version of the book ... it isn't a replacement. If you find the podcast remotely helpful, order the book.
To read the full review or view more technical book reviews like this, visit [...].
I'd like to thank the author of this book for writing it.
I've been writing unit tests for quite some time now and this book contributed my knowledge tremendously.
Before this book, I had a lot of questions to ask about unit testing and most of them where "how?" questions.
How to write a good unit test ?
How to write tests in isolation and decouple the dependencies in complex scenarios ?
How to write fake objects properly and understand the differences between the various fake objects in Unit Testing.
How to write scalable and maintainable unit tests ?
The only thing I dislike and I think the author should reconsider is the remark about virtual methods "Make methods virtual by default" while this may be convenient it comes with serious implications and I think there's a lot more to write about it rather than suggesting developers that they should do so, even though he wrote an alternative, the title says it all.
However, this book definitely stands for its title!
Of course, if you are at the point you have to write unit tests, you have a job programming, so this book is certainly not for beginners (at least not in computing). The examples are in C# but the language is not very important for this book
He uses a different set of programs as the base of his examples, but this doesn't matter much, because the techniques he presents are very useful. The very first unit test I wrote after reading only a couple of chapters was way better, and easier to write and understand than the one I wrote just before it. And the one after I finished the book was even better.
As he mentions somewhere in the book, any type of testing is viewed as a waste of time, but the quality of the code improves a lot. He presents not only how and why to start writing unit tests but how to convince your company how to do it.
The book paid for itself a couple of times already, even though I only had it for about a month.
I found this book very helpful with its suggestions on how to set up tests, what kinds of tests to use in any given scenario. I didn't really know before reading it, that unit tests should not have any external dependancies (i.e. database, file system, etc, etc.).
There are many examples in this book and was very invaluable to me. Highly recommend you pick up this book.