# Java Level 12: Testing

> Level 12: Testing of the LoWisa Java course: Unit and Integration Tests, Mocking and Test Design, Maintainable Java Test Suites. 3 lessons and 9 ideas, each explained in one line.

Testing is level 12 of 16 of the [LoWisa Java course](/courses/java/). It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

## Unit and Integration Tests

- **JUnit.** A **JUnit** test is an annotated method whose assertions define pass: run by the build on every change.
- **Test scope.** Unit tests isolate one class; **integration** tests wire real pieces: both, in a fast-to-slow pyramid.
- **Naming behaviour.** Name tests by **behaviour**: refundRejectedWhenOrderUnpaid reads as the specification it is.

## Mocking and Test Design

- **Test doubles.** A **mock** stands in for a collaborator: the test scripts its answers and verifies the conversation.
- **Constructor injection.** Passing dependencies through **constructors** makes substitution trivial: testability is a design property.
- **Don’t over-mock.** Mock the **boundaries**: network, clock, database: and use real objects inside; over-mocked tests pin implementation, not behaviour.

## Maintainable Java Test Suites

- **Determinism.** Reliable suites are **deterministic**: fixed clocks, seeded data, no order dependence, no real network.
- **Test data builders.** A **builder** for test objects: anOrder().paid().build(): keeps tests readable as requirements change.
- **Fast feedback.** A suite that runs in **seconds** is run always; a slow one gets skipped, then trusted, then wrong.

## Before and after this level

- **Before:** [Level 11: Networking & Data](/courses/java/level-11-networking-and-data/): HTTP and Network Programming, JDBC and Database Access, Reliable External Integrations.
- **Next:** [Level 13: Modern Java](/courses/java/level-13-modern-java/): Records and Pattern Matching, Modern Language Features, Writing Idiomatic Current Java.

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See [Checkpoints and flashcards](/help/checkpoints-and-flashcards/).

## Frequently asked questions

### What does Java Level 12: Testing cover?

Unit and Integration Tests, Mocking and Test Design, Maintainable Java Test Suites: 3 lessons and 9 ideas.

### What should I know before this level?

The level before it, Level 11: Networking & Data, which covers HTTP and Network Programming, JDBC and Database Access, Reliable External Integrations.

## Learn Java on your phone

The first level is free. LoWisa is on Google Play and the App Store.

---

Source: https://lowisa.dev/courses/java/level-12-testing/ · Updated 2026-11-16
