Unit Testing & Spring Test Framework

Testing Software From Developers' Point-of-View

Unit Tests...

  • verify the functionality of a specific section of code

  • written by developers
  • white-box style testing

  • usually at the method level

  • in OOP, usually at the class level

  • automated tests as documentation

Unit Tests...

  • find problems early
  • easier refactoring

Unit Tests...

  • like writing client for your code
  • make you to look at the user's (other developer's or just yourself's) perspective

Unit Tests...

"A failure in a high-level test is not just a bug in functional code, it's also a missing unit test"

~Martin Fowler

Unit Tests & TDD

Test-Driven Development lifecycle

How to Practice on Unit Testing & TDD?

  • Find test-less modules via SonarQube and write tests for them
  • Read test codes written by others
  • Pair Programming
  • Use TDD Code Katas:

Code Coverage...

is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs.


  • Line coverage
  • Method coverage
  • Class coverage

Code Coverage...

"I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence..."
~Kent Beck

Continuous Integration

In XP, CI was intended to be used in combination with automated unit tests written through the practices of test-driven development.

Unit Testing Libraries for Java

Unit Testing Examples for Java

Contains various testing examples for Java projects:



Unit Testing & Spring Test Framework

By Ufuk Uzun

Unit Testing & Spring Test Framework

  • 2,147