Testing y TDD para PHP
Testing y TDD para PHP
Sobre este libro
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.
Bundles that include this book
Tabla de contenido
-
Acerca de este libro
- Gracias
-
Introducción: Del ojímetro al tdd
- Entonces descubres los tests
- Control de calidad
- Tests funcionales
- Anatomía de un test
- Manejo de las dependencias
- Cuándo toca hacer tests
- Test Driven Development
- Qué incluir en los tests y qué no
- Y esto es casi todo
-
Testing desde cero
- Qué es software testing
- A mano o a máquina
- Qué sometemos a test
- Qué es hacer un test
- Estructura básica de un test
- La elección de los casos para testear
- Frameworks para testing
- Cuándo testear
-
Testing en contexto
- Taxonomía de tests
- La pirámide de tests funcionales
- Utilidad de la pirámide de tests
- Smells en la pirámide de los tests funcionales
-
Psicología del testing
- ¿Por qué nos cuesta el testing?
- El concepto de test y la necesidad de testear
- Sentimos apego por nuestro código
- La dificultad técnica del testing
- La presión para no testear
- Testear no es igual a confirmar que funciona
- Responsabilidad ética y testeo
-
Primer test
- Frameworks al rescate
- El primer test
- Testeando que podemos añadir productos al carro
- Redundancia de tests
- Otros tests
- Descubriendo implementaciones incorrectas
- Últimos tests
- Hemos terminado… de momento
-
Un ejercicio para aprender TDD
- Repasando conceptos
- La kata del DNI
- El ciclo red-green-refactor
- Volviendo al rojo: hagamos un nuevo test
- Refactor
- Retomando el desarrollo
- El curioso problema de los tests que pasan a la primera
- Resolución de bugs mediante TDD
-
Desarrollar un algoritmo paso a paso con TDD: Luhn Test kata
- Sobre la Luhn Test kata
- Empecemos con un test
- Empezando con el código de producción
- Buscando un nuevo ejemplo
- Los tests deben forzar implementaciones
- Buscando un algoritmo más general
- Añadiendo prestaciones
-
Clean testing
- Naming de los test
- Eliminar los números mágicos
- Extrae métodos, también en tests
- Esperar excepciones
-
Métodos
assert*
-
Test doubles (1)
- El concepto de test double
- Por qué y para qué de los tests doubles
- Test doubles y dónde encontrarlos
- Alternativas para generar test doubles
-
Test doubles (2) Principios de diseño
- Principios de diseño y doubles
- Un ejemplo
- En resumen
-
Test doubles 3: un proyecto desde cero
- Las piezas del puzzle
- Test doubles en acción
- Cómo hacer Test Driven Development de un Use Case
- Reorganizando el test
- Asegurando que el Cliente puede contratar el Producto
- Cuando necesitamos hacer mocks
- Usar un spy hecho a mano
- Qué ha pasado aquí
- Qué hacer a continuación
-
Resolver problemas con baby-steps
- Un problema sencillo, pero con intríngulis
- Un problema de TDD
- El enfoque de tests antes que el código pero que no es TDD
- El enfoque TDD
- Conclusiones
-
Usar el code coverage para mejorar los tests
- Code coverage y refactoring
- Para finalizar
-
Testeando lo impredecible
- Generando contraseñas para humanos
- Determinismo y predictibilidad
- A ver qué sale
- Generando un password legible
- Testeando el azar
- Probamos nuestro generador de contraseñas
- Queremos contraseñas más difíciles
- Decorar es extender por composición
- Veamos cómo usarlo
- Cosas por hacer
- Algunas referencias
-
TDD en PHP. Un ejemplo con colecciones (1)
- ¿Qué tendría que tener una clase Collection?
- Escribiendo el primer mínimo test que falle
- Pongamos un poco de comportamiento aquí
- Controlando qué ponemos en la colección
- Refactorizar el test
- Antes de terminar, hagamos unos arreglos
- Y un extra
- Fin del primer acto
-
TDD en PHP. Un ejemplo con colecciones (2)
- Testing dirigido por Checklist
- Filosofía de las colecciones
-
Implementar el método
each
-
Recapitulando
each
-
TDD en PHP. Un ejemplo con colecciones (3)
-
Pipeline en el método
each
- Una digresión: mutable, modificable o todo lo contrario
-
Antes de implementar el método
map
-
Implementando
map
- Para finalizar (por ahora)
-
Pipeline en el método
-
TDD en PHP. Un ejemplo con colecciones (4)
- Estos capítulos tratan de TDD más que de Collections
- Filtrando una colección
- Ahorrando algunos tests con return type y type hinting
- ¿Algo que refactorizar?
- Devolver un objeto
- Fin del capítulo
-
TDD en PHP. Un ejemplo con colecciones (5)
- Reduciendo colecciones
- Métodos útiles para nuestras colecciones
- Devolviendo el contenido de la colección
- Métodos de utilidad
- Refactor final
- Apéndices
-
Apéndice 1: PhpUnit
- Instalación
- Configuración básica
-
Apéndice 2: PhpSpec
- Instalación
- Configuración inicial
- Specification by example
- Primera especificación
-
Apéndice 3: Codeception
- Instalación
- Ejemplo de uso
-
Apéndice 4: Talking Bit dojo + PHPStorm
- Uso básico de docker
- Configuración de PHPStorm
- Consideraciones finales
- Notas
Leanpub incondicional, sin riesgo, 100% de felicidad garantizada
Durante los primeros 60 días de compra, puedes obtener un reembolso del 100% de cualquier compra Leanpub, en dos clics. Procesamos las restituciones manualmente, así que puede tomarse unos días en aparecer. Véase términos completos.
Que estés bien. Haz el bien.
Authors have earned$11,714,583writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
Actualizaciones gratis. Libre de DRM.
¡Si compras un libro Leanpub obtienes actualizaciones gratis siempre y cuando el autor actualice el libro! Varios autores usan Leanpub para publicar sus libros en progreso mientras los escriben. Todos los lectores obtienen actualizaciones gratis, independientemente de cuándo compraron el libro o cuánto pagaron (incluyendo si fue gratis).
La mayoría de los libros Leanpub se encuentran disponibles en PDF (para computadores), EPUB (para teléfonos y tabletas) y MOBI (para Kindle). Los formatos que un libro incluye se muestran en la esquina superior derecha de esta página.
Finalmente, los libros Leanpub no tienen ninguna de las cosas sin sentido sobre protección de copia DRM, así que puedes leerlos fácilmente en cualquier dispositivo que se soporta.
Aprende más sobre los formatos de Leanpub y dónde puedes leerlos
Top Books
Recipes for Decoupling
Matthias NobackWrite software that survives
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
CQRS by Example
Carlos Buenosvinos, Christian Soronellas, and Keyvan Akbary- Leverage your Software Architecture skills by learning everything about CQRS in detail with lots of examples
- Develop faster applications by applying CQRS and fostering Read Models and Projections
- Learn how to apply CQRS into a brownfield project from a pragmatic approach
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Maîtriser Apache JMeter
Philippe Mouawad, Bruno Demion (Milamber), and Antonio Gomes RodriguesToute la puissance d'Apache JMeter expliquée par ses commiteurs et utilisateurs experts. De l'intégration continue en passant par le Cloud, vous découvrirez comment intégrer JMeter à vos processus "Agile" et Devops.
If you're looking for the newer english version of this book, go to Master JMeter : From load testing to DevOps
Jetpack Compose internals
Jorge CastilloJetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.
The PowerShell Scripting and Toolmaking Book
Don Jones and Jeff HicksLearn the patterns, practices, and details of PowerShell Scripting and Toolmaking from the industry's two most recognized experts on the subject.
Mastering STM32 - Second Edition
Carmine NovielloWith more than 1200 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the most complete guide around introducing the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL and STM32CubeIDE development environment.
Introduction to Data Science
Rafael A IrizarryThe demand for skilled data science practitioners in industry, academia, and government is rapidly growing. This book introduces concepts from probability, statistical inference, linear regression and machine learning and R programming skills. Throughout the book we demonstrate how these can help you tackle real-world data analysis challenges.
Top Bundles
- #1
Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #4
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #6
All the Books of The Medical Futurist
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon...