The idea
Green does not mean correct
AI agents generate more and more code, faster and faster. You write unit tests to make sure that this code works. Most people stop at example-based testing. A known output is verified for a known input. That works as long as everyone thinks of all the relevant cases. But what about the cases nobody thought of?
In this training you get to know methods with which you make sure that your tests really verify the right thing. You secure existing code before you change it. You automatically find edge cases you would never have thought of. And you understand why high code coverage alone is no guarantee of quality.
These methods are not tied to PHP. Sebastian teaches the concepts using PHP examples with the tools of the PHP ecosystem. You take the insights with you into any codebase. Whether PHP, C#, Go, Java, Python, Rust, or TypeScript.
The programme
Five sessions, five methods
Each session is devoted to one method that goes beyond example-based testing. Two hours, live and interactive. We work on real code, not on slides.
Meaningful tests
2 hours- Your test is green. But how do you know that it verifies the right thing?
- What happens when your code produces correct results but has unwanted side effects?
- How do you verify behaviour that is not expressed in a return value?
- What do you do when you do not even know what the correct answer would be?
Modernising safely
2 hours- You are supposed to change code that nobody on the team understands. There are no tests and no documentation.
- How can you modernise safely when you do not know what the code actually does?
- How do you document the actual behaviour before you change anything?
- How do you get from a safety net to a real test suite?
What nobody thinks of
2 hours- You test with examples, but you cannot write down all the examples. What do your tests miss?
- How do you find edge cases you would never have thought of?
- When a test fails, the input is often huge and incomprehensible. How do you get to the actual problem?
- For which kinds of code is this approach worthwhile, and where does it reach its limits?
The blind spot
2 hours- You have high code coverage, but bugs still make it into production. Why?
- Your tests are green, but would they even notice a real defect in the code?
- How do you measure whether your tests are actually any good, beyond coverage numbers?
- What do controlled defects in the code tell you about the quality of your test suite?
What nobody expects
2 hours- Your tests show that your code does the right thing for the inputs you expect. But is it also robust?
- What happens when your code receives input that nobody expected?
- Why does even 100% code coverage not protect you from all defects?
- How do you find security vulnerabilities before attackers do?
How to turn a vulnerability you have found into a test that keeps it from coming back is the subject of Test-Driven Security.
Who it is for
Experienced developers
This training is aimed at everyone who already has experience with automated tests and wants to broaden their testing methodology. The concepts are relevant regardless of the programming language you use. We implement the practical examples in PHP; you transfer the methods directly to other languages. If your concern is a PHPUnit test suite that is slow, fragile, or hard to understand, Advanced PHPUnit is the better fit.
What you take away
- You recognise when a green test is deceptive, and make sure that it verifies the right thing
- You secure unknown code before you change it
- You find edge cases you would never have thought of when writing tests by hand
- You know what code coverage really tells you, and what it does not
- You systematically verify the robustness of your code against unexpected input
- You choose the right testing method for every situation and can justify your decision
What you bring
- Experience in software development with an object-oriented programming language
- Basic experience with automated tests: you write and run unit tests
- Basic knowledge of PHP is helpful for the practical examples, but not strictly required
- For the exercises in sessions 3 to 5, Podman or Docker for the container you receive in advance
- Curiosity about testing methods beyond your everyday work
Your trainer
Sebastian Bergmann
Sebastian is the creator of PHPUnit, the de facto standard for testing PHP code. Since 2001 he has been helping teams build maintainable and well-tested software as a consultant and trainer, since 2009 as a co-founder of thePHP.cc.
You work with him live on real code and ask your questions directly.
Registration
Five interactive live sessions of two hours each, as a Zoom meeting. Small group, real code, your questions.