Search⌘ K
AI Features

Challenge: Grade System—Stubs and Mocks

Explore how to implement and test a GradesService class in Java using stubs to simulate the Gradebook dependency. Learn to write unit tests that provide predefined data, calculate averages, and assert results for reliable test-driven development.

We'll cover the following...

Task and requirements

You’re given a GradesService class that calculates the average grades for a student. The GradesService depends on a Gradebook class, which retrieves the grades for a student. Your task is to write a test for the GradesService class using a stub to simulate ...