Leanpub Header

Skip to main content

Testing y TDD para PHP

Este es un manual que recoge ideas y experiencias sobre testing y test driven development. Aunque la mayoría de los ejemplos de código están hechos en PHP, el contenido es aplicable a otros lenguajes.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
199
Readers
418
Pages
About

About

About the Book

Este es un manual que recoge ideas y experiencias sobre testing y test driven development. Aunque la mayoría de los ejemplos de código están hechos en PHP, el contenido es aplicable a otros lenguajes. Se trata de una recopilación de artículos publicados en el blog de The Talking Bit y reflejan la evolución de mi experiencia y aprendizaje escribiendo tests y haciendo test driven development.

Share this book

License

Creative Commons Attribution-ShareAlike 4.0 International License

Price

Pick Your Price...

Minimum price

$7.99

$7.99

You pay

$7.99

Author earns

$6.39
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 1)

1
The author will earn $12.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Fran Iglesias

Soy un desarrollador backend que trabaja sobre todo con PHP, aunque no dejo de explorar y probar otros lenguajes. Me interesan mucho las buenas prácticas, especialmente el testing y el test/behavior driven development.

Translations

Translations

Languages

Contents

Table of Contents

Acerca de este libro

  1. Gracias

Introducción: Del ojímetro al tdd

  1. Entonces descubres los tests
  2. Control de calidad
  3. Tests funcionales
  4. Anatomía de un test
  5. Manejo de las dependencias
  6. Cuándo toca hacer tests
  7. Test Driven Development
  8. Qué incluir en los tests y qué no
  9. Y esto es casi todo

Testing desde cero

  1. Qué es software testing
  2. A mano o a máquina
  3. Qué sometemos a test
  4. Qué es hacer un test
  5. Estructura básica de un test
  6. La elección de los casos para testear
  7. Frameworks para testing
  8. Cuándo testear

Testing en contexto

  1. Taxonomía de tests
  2. La pirámide de tests funcionales
  3. Utilidad de la pirámide de tests
  4. Smells en la pirámide de los tests funcionales

Psicología del testing

  1. ¿Por qué nos cuesta el testing?
  2. El concepto de test y la necesidad de testear
  3. Sentimos apego por nuestro código
  4. La dificultad técnica del testing
  5. La presión para no testear
  6. Testear no es igual a confirmar que funciona
  7. Responsabilidad ética y testeo

Primer test

  1. Frameworks al rescate
  2. El primer test
  3. Testeando que podemos añadir productos al carro
  4. Redundancia de tests
  5. Otros tests
  6. Descubriendo implementaciones incorrectas
  7. Últimos tests
  8. Hemos terminado… de momento

Un ejercicio para aprender TDD

  1. Repasando conceptos
  2. La kata del DNI
  3. El ciclo red-green-refactor
  4. Volviendo al rojo: hagamos un nuevo test
  5. Refactor
  6. Retomando el desarrollo
  7. El curioso problema de los tests que pasan a la primera
  8. Resolución de bugs mediante TDD

Desarrollar un algoritmo paso a paso con TDD: Luhn Test kata

  1. Sobre la Luhn Test kata
  2. Empecemos con un test
  3. Empezando con el código de producción
  4. Buscando un nuevo ejemplo
  5. Los tests deben forzar implementaciones
  6. Buscando un algoritmo más general
  7. Añadiendo prestaciones

Clean testing

  1. Naming de los test
  2. Eliminar los números mágicos
  3. Extrae métodos, también en tests
  4. Esperar excepciones
  5. Métodos assert*

Test doubles (1)

  1. El concepto de test double
  2. Por qué y para qué de los tests doubles
  3. Test doubles y dónde encontrarlos
  4. Alternativas para generar test doubles

Test doubles (2) Principios de diseño

  1. Principios de diseño y doubles
  2. Un ejemplo
  3. En resumen

Test doubles 3: un proyecto desde cero

  1. Las piezas del puzzle
  2. Test doubles en acción
  3. Cómo hacer Test Driven Development de un Use Case
  4. Reorganizando el test
  5. Asegurando que el Cliente puede contratar el Producto
  6. Cuando necesitamos hacer mocks
  7. Usar un spy hecho a mano
  8. Qué ha pasado aquí
  9. Qué hacer a continuación

Resolver problemas con baby-steps

  1. Un problema sencillo, pero con intríngulis
  2. Un problema de TDD
  3. El enfoque de tests antes que el código pero que no es TDD
  4. El enfoque TDD
  5. Conclusiones

Usar el code coverage para mejorar los tests

  1. Code coverage y refactoring
  2. Para finalizar

Testeando lo impredecible

  1. Generando contraseñas para humanos
  2. Determinismo y predictibilidad
  3. A ver qué sale
  4. Generando un password legible
  5. Testeando el azar
  6. Probamos nuestro generador de contraseñas
  7. Queremos contraseñas más difíciles
  8. Decorar es extender por composición
  9. Veamos cómo usarlo
  10. Cosas por hacer
  11. Algunas referencias

TDD en PHP. Un ejemplo con colecciones (1)

  1. ¿Qué tendría que tener una clase Collection?
  2. Escribiendo el primer mínimo test que falle
  3. Pongamos un poco de comportamiento aquí
  4. Controlando qué ponemos en la colección
  5. Refactorizar el test
  6. Antes de terminar, hagamos unos arreglos
  7. Y un extra
  8. Fin del primer acto

TDD en PHP. Un ejemplo con colecciones (2)

  1. Testing dirigido por Checklist
  2. Filosofía de las colecciones
  3. Implementar el método each
  4. Recapitulando each

TDD en PHP. Un ejemplo con colecciones (3)

  1. Pipeline en el método each
  2. Una digresión: mutable, modificable o todo lo contrario
  3. Antes de implementar el método map
  4. Implementando map
  5. Para finalizar (por ahora)

TDD en PHP. Un ejemplo con colecciones (4)

  1. Estos capítulos tratan de TDD más que de Collections
  2. Filtrando una colección
  3. Ahorrando algunos tests con return type y type hinting
  4. ¿Algo que refactorizar?
  5. Devolver un objeto
  6. Fin del capítulo

TDD en PHP. Un ejemplo con colecciones (5)

  1. Reduciendo colecciones
  2. Métodos útiles para nuestras colecciones
  3. Devolviendo el contenido de la colección
  4. Métodos de utilidad
  5. Refactor final

Apéndices

Apéndice 1: PhpUnit

  1. Instalación
  2. Configuración básica

Apéndice 2: PhpSpec

  1. Instalación
  2. Configuración inicial
  3. Specification by example
  4. Primera especificación

Apéndice 3: Codeception

  1. Instalación
  2. Ejemplo de uso

Apéndice 4: Talking Bit dojo + PHPStorm

  1. Uso básico de docker
  2. Configuración de PHPStorm
  3. Consideraciones finales

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub