Good Unit Tests
Understanding what “Good Unit Tests” are and learning how to write them enables you and your team to gain real benefits from your unit testing efforts. Mastering a few essential techniques ensures your unit tests are maintainable, readable, and trustworthy.
Overview
By joining this training, you’ll learn what defines *Good Unit Tests* and how you and your team can experience the tangible benefits of unit testing.Contrary to common belief, the greatest benefit of writing unit tests the right way is not bug-free code nor full regression test coverage. The real value lies in how good unit tests positively influence your code design, making it inexpensive to change. Good Unit Tests guide you to discover and apply strong object-oriented design principles and practices, ultimately reducing the cost of change over time.
As a result, you’ll see the highest reward in the long-term durability of your code, which will be equipped to stand the test of time.
Studies show that increasing code quality enhances productivity, boosts efficiency, and shortens development schedules. Mastering the art of unit testing is a powerful step toward elevating your project’s overall quality.
Motivation
Many teams struggle to benefit from unit testing, not due to a lack of motivation or belief, but because they misunderstand what unit testing truly involves and lack key skills to write effective tests. Done poorly, unit testing can become a burden—slowing progress, draining motivation, and even reducing code quality.
However, when approached correctly, unit testing forces developers to slow down, think carefully, and write clean code that works. It helps reduce accidental complexity, making your product simpler and more reliable.
Learning Objectives
- Achieve a correct understanding of what unit testing is
- Learn how to obtain a healthy suite of unit tests, from which you get real benefits
- Learn how to write unit tests that last and have a low maintainability cost
- Learn how to benefit from the positive pressure the unit tests put on your production code driving it to a better code design
- Learn techniques of refactoring the production code towards a testable design
- Learn techniques of adding automated tests to legacy code
Target Audience
Any software developer would benefit greatly from this training.
Powerhouse Format Outline
➟ online only: one 4-hour session
The Powerhowse Workshop format is a concise, cost-effective, and impactful learning experience. In this format, the content is condensed without extensive details or hands-on labs, making it accessible to a broad audience
Outline:
- Basics of Unit Testing
- Understanding Mocks and Stubs
- Core Techniques for Good Unit Tests
- Good Unit Tests Ask for Quality Code
- Maintaining the Unit Test Code
- The Three Pillars of Good Unit Tests
- Automated Test Types
Standard Format Outline
➟ onsite: two full days
➟ online: three days with 4-hour sessions each
The training is structured in two parts. First part focuses on explaining, exemplifying, and discussing the technical concepts to reach the targeted learning objectives. The second part is hands-on and focuses on demonstrating and exercising the techniques discussed in the first part.
Custom formats are also available, offering extended durations which focus more on practicing, and applying these concepts on a specific project or context. This would contribute to adopting the practices of Good Unit Tests by project teams.
Outline
Section 1: Basics of Unit Testing
- What is a GOOD Unit Test
- What is an Integration Test
- Why write Unit Tests
- What to test
- How many unit tests will we have
Section 2: Tools and Frameworks
- Test Frameworks
- Isolation Frameworks
- Code Coverage Tools
Section 3: Core Techniques for GOOD Unit Tests
- Isolation
- Test Inhibiting Design to TOOD
- Understanding Mocks vs Stubs
- Test Doubles
Section 4: Good Unit Tests Ask for Quality Code
- Why we want quality code
- Getting to quality code by doing Good Unit Testing
- Patterns and Principles emerging from the Good Unit Test positive pressure
- Test Code Cycle
- Code Coverage Pressure
Section 5: The Unit Test Code
- Testing an Abstract Class
- Good Practices for Writing Unit Tests
- Unit Test Types
- Test Class Inheritance Patterns
- Organizing Unit Test Code
Section 6: The Three Pillars of GOOD Unit Tests
- Readability
- Maintainability
- Trustworthiness
Section 7: Automated Test Types
- Tests granularity
- Types of Integration tests
- Adding Automated Tests to Legacy Code