Overview
Explore effective unit testing techniques in this 48-minute conference talk from Devoxx. Delve into key aspects of robust testing, including flakiness, debuggability, reproducibility, speed, specificity, independence, and timing. Learn how to eliminate unclear input/output, handle thread safety, and understand crucial facts about unit testing. Discover best practices for creating fast, clear, and reliable tests while avoiding conditional logic. Gain insights on refactoring and development practices to enhance your testing approach. Although examples are in Java and JUnit, the principles apply to all languages and test frameworks.
Syllabus
Intro
Why do we write unit tests?
Eliminate everything that makes input or output unclear or contingent
Why Unit Tests?
Tests and Thread Safety
The Two Least Known Facts of Unit Testing
1. Tests do not share instance data
2. You can have many test classes per model class.
Speed
Passing tests should produce no output
Failing tests should produce clear output
Flakiness
System Skew
Avoid Conditional Logic in Tests
Refactoring
Development Practices
Final Thoughts
Taught by
Devoxx