Description
In this course, you will :
- Learn how to use JUnit to test Java applications effectively.
- Learn about the fundamental quality principles of unit testing.
- Learn how to write cleaner and refactored JUnit tests.
Syllabus :
1. JUnit Test Foundations
- Reasons to Write Unit Tests
- Introduction to Building JUnit Test
- Our First Passing Test
- Arrange, Act, and Assert Your Way to a Test
- Understanding What We’re Testing: The Profile Class
- Let's Write Tests
- Initializing Tests with @Before Methods
2. Digging Deeper into JUnit Assertions
- Introduction to Assertions in JUnit
- A Classic-Style Assertion: assertTrue
- Hamcrest Assertions
- Decorators
- Comparing Two Floating-Point Numbers
- Assertion Messages
- Testing the Expected Exceptions
- Expected Exceptions using JUnit
3. Organizing Your Tests
- Follow the AAA Pattern
- Test Behaviors not Methods
- Relationship Between Test and Production Code
- Focused and Single-purpose Tests
- Test Documentation
- Using Annotations
- Green Is Good
4. Mastering Manic Mnemonics!
- FIRST: Properties of Good Tests
- [F]IRST: [F]ast
- F[I]RST: [I]solate Your Tests
- FI[R]ST: Good Tests Should Be [R]epeatable
- FIR[S]T: [S]elf-Validating
- FIRS[T]: [T]imely
5. What to Test: The Right-BICEP
- The Right-BICEP
- [Right]-BICEP: Are the Results Right?
- Right-[B]ICEP: Boundary Conditions
- Right-B[I]CEP: Checking Inverse Relationships
- Right-BI[C]EP: Cross-Checking Using Other Means
- Right-BIC[E]P: Forcing Error Conditions
- Right-BICE[P]: Performance Characteristics
6. Boundary Conditions: The CORRECT Way
- The CORRECT Way
- [C]ORRECT: [C]onformance
- C[O]RRECT: [O]rdering
- CO[R]RECT: [R]ange
- COR[R]ECT: [R]eference
- CORR[E][C]T: [C]ardinality and [E]xistence
- CORREC[T]: [T]ime
7. The Bigger Design Picture
- Refactoring to Cleaner Code
- Finding Better Homes for Our Methods
- Automated and Manual Refactorings
- How much Refactoring?
8. Bigger Design Issues
- SOLID class design principles
- The SRP and Profile class
- Command-query separation principle
- Test Maintenance Cost
- Other Design Thoughts
9. Using Mock Objects
- A Testing Challenge
- Replacing Troublesome Behavior with Stubs
- Changing Our Design to Support Testing
- Simplifying Testing using a Mock Tool
- One Last Simplification: Introducing an Injection Tool
- What’s Important to Get Right When Using Mocks?
10. Refactoring Tests
- Searching for an Understanding
- Test Smell: Unnecessary Test Code
- Test Smell: Missing Abstractions
- Test Smell: Irrelevant Information
- Test Smell: Bloated Construction
- Test Smell: Multiple Assertions
- Test Smell: Irrelevant Details
- Test Smell: Implicit Meaning and Misleading Organization
- Adding a New Test
11. The Bigger Unit-Testing Picture
- Test-Driven Development
- TDD Cycle
- Smallest Possible Increment
- Code Refactoring
- Another Small Increment
- Supporting Multiple Answers: A Small Design Detour
- Expanding the Interface
- Last Tests
- Tests As Documentation
12. Testing Some Tough Stuff
- Testing Multithreaded Code
- Extracting Application Logic
- Redesigning the Threading Logic
- Testing Databases
- The Data Problem
- Cleaning the Database and Mocking the Controller
13. Testing on a Project
- Coming up to Speed
- One Team, One Unit
- Convergence with Continuous Integration
- Code Coverage