API / Apache Grails Interview questions
What is the difference between unit tests and integration tests in Grails testing?
Both verify application behavior, but they differ in scope, speed, and how much of the real Spring/GORM machinery is actually running behind the test.
| Unit test | Integration test |
| Tests one class in isolation, with dependencies mocked | Tests multiple layers working together (controller + service + GORM) |
| Fast; no full Spring context startup required | Slower; starts a real (or near-real) application context |
| GORM operations often use a lightweight, mocked implementation | Uses a real (often in-memory or test) database and full GORM persistence |
| Good for pinpointing exactly where a bug lives | Good for catching wiring/integration mistakes unit tests can't see |
A healthy test suite typically leans heavily on fast unit tests for the bulk of business-logic coverage, reserving the slower integration tests for the smaller set of cases that genuinely need to verify multiple real layers actually cooperate correctly — something no amount of isolated unit testing, by definition, can catch on its own.
More Related questions...