- Tapa blanda: 402 páginas
- Editor: Tomasz Kaczanowski (23 de abril de 2013)
- Idioma: Inglés
- ISBN-10: 8393489393
- ISBN-13: 978-8393489398
- Valoración media de los clientes: 2 opiniones de clientes
- Clasificación en los más vendidos de Amazon: nº73.082 en Libros en idiomas extranjeros (Ver el Top 100 en Libros en idiomas extranjeros)
Practical Unit Testing with JUnit and Mockito (Inglés) Tapa blanda – 23 abr 2013
|Nuevo desde||Usado desde|
Los clientes que compraron este producto también compraron
Descripción del producto
Reseña del editor
This book explains in detail how to implement unit tests using two very popular open source Java technologies: JUnit and Mockito. It presents a range of techniques necessary to write high quality unit tests - e.g. mocks, parametrized tests and matchers. It also discusses trade-offs related to the choices we have to make when dealing with some real-life code issues.
The book stresses the importance of writing readable and maintainable unit tests, and puts a lot of stress on code quality. It shows how to achieve testable code and to eliminate common mistakes by following the Test Driven Development approach. Every topic discussed in the book is illustrated with code examples, and each chapter is accompanied by some exercises.
By reading this book you will:
- Grasp the role and purpose of unit tests
- Write high-quality, readable and maintainable unit tests
- Learn how to use JUnit and Mockito (but also other useful tools)
- Avoid common pitfalls when writing unit tests
- Recognize bad unit tests, and fix them in no time
- Develop code following the Test Driven Development (TDD) approach
- Use mocks, stubs and test-spies intelligently
- Measure the quality of your tests using code coverage and mutation testing
- Learn how to improve your tests' code so it is an asset and not a burden
- Test collections, expected exceptions, time-dependent methods and much more
- Customize test reports so that they show you what you really need to know
- Master tools and techniques your team members have never even heard of (priceless!) :)
Nowadays every developer is expected to write unit tests. While simple in theory, in practice writing high-quality unit tests can turn out to be a real challenge. This book will help.
Biografía del autor
Tomek Kaczanowski is a technical team leader from Krakow, Poland. He has a strong interest in code quality, testing and automation - preferably all three together. Combining technical with soft skills, he also ventures into the realms of mentoring, teaching, lecturing and article writing, not to mention preaching sermons to the unconverted in the hope of redeeming them (or at least their code)! He hates doing things manually, and is allergic to empty src/test/java directories. Tomek believes that by working with legacy code, and improving it, he can make the world a better place. To his disappointment, the world does not seem to care all that much about his efforts. Apart from all this weirdness, he is a pretty normal person – a husband, father of two, and cat owner.
No es necesario ningún dispositivo Kindle. Descárgate una de las apps de Kindle gratuitas para comenzar a leer libros Kindle en tu smartphone, tablet u ordenador.
Obtén la app gratuita:
Detalles del producto
Si eres el vendedor de este producto, ¿te gustaría sugerir ciertos cambios a través del servicio de atención al vendedor?
Opiniones de clientes
Principales opiniones de clientes
Ha surgido un problema al filtrar las opiniones justo en este momento. Vuelva a intentarlo en otro momento.
En la forma de presentar los casos y ejemplos se nota que es alguien que ha trabajado en el sector y que tiene las ideas claras. No creo que aporte mucho para quién quiera aprender Mockito ya que el libro no está desarrollado como un manual de Mockito sino que se concentra en explicar métodos para crear pruebas unitarias fácilmente mantenibles. se concentra en como hacer los
Uno de los libros sobre "testing" con los conceptos más claros y didácticos que he leído
Opiniones de clientes más útiles en Amazon.com
- The theory is good and easy to understand.
- Hardly any examples in the book. There are no detailed TDD examples as well.
- End of book exercises are way more difficult than the sparse examples in the book.
- No guide or solutions to the end of chapter exercises. So, you don't know if you are doing TDD "correctly".
- Author does not reply to (succinct, polite and non spammy) emails that request for help.
Verdict: Might be good for people who have learned some TDD at work and/or practiced TDD in a language other than Java and want to learn Junit and Mockito.
PS: I would give the book 5 stars and pay $100 more for it, if it had detailed step by step solutions for all the exercises.
However, I'm going to spend a bit more time on the problems, because they're more interesting to talk about, but not because the book is only problems.
1) It needs a bit more editing. Certain parts of the book are not formatted well, and it is pretty noticeable. Again, reader, keep in mind my 4 star rating, it's not *SO BAD* to make it unreadable, just in a few places you get surprised by such a noticeable and easily fixable formatting problem.
2) It needs more integrated examples. Many of the examples are kept simple, which makes them clear about that particular concept, but then you look at your existing code and realize that it's significantly more complicated than the example in this book, and it's not so easy to transfer the use cases. A chapter on doing exactly that, looking at more complicated code and figuring out how to test it would be extremely helpful.
3) I bought this book because I have a reasonably complicated project than I wanted to learn how to test before I moved onto deployment. I would think that most of the people buying this book would be in that situation... it is a rare person who would think about testing before the code is actually written, unless you're already used to thinking that way. This book spends a large amount of time talking about that concept (Test Driven Development, or TDD) - it is the entirety of Chapter 4. However, I suspect that most readers either 1. already know about TDD and are using it, and therefore don't need that much of an in depth discussion of it, or 2. are like me, and are looking to test existing software. In my opinion, this book spends too much energy trying to teach people to use TDD, and not enough effort helping people add tests to their existing code that wasn't designed with TDD, nor enough effort on how to refactor existing code to make it more testable.
4) This is related to #3. I wish this book had a section on, "okay, your test has failed, but you don't know why". How can you modify your test and use a debugger to figure out why the test failed and how can you fix it? For example, if you use a mockito mock, and you say "verify that this method was called once" and it was called twice, what could/should you do to figure out where it was called from?
If you're looking for a book that teaches the latest versions of JUnit, Mockito, and related packages (CatchException, PowerMock, etc.), this book is for you. If you're looking for a book that will help you debug existing code and write tests for existing code, this book is not as helpful.
Not only are the examples practical, Tomek addresses discusses real dilemmas that we face in application testing. Check out the "Points of Controversy", real good stuff in that chapter for the experienced as well as the inexperienced.