Debug and Fix Failing Unit Tests in Java

Quick Overview

This question evaluates proficiency in debugging and maintaining a Java codebase with failing unit tests, testing competencies in unit testing, fault isolation, reading test assertions and stack traces, and verifying regression-free fixes.

Debug and Fix Failing Unit Tests in Java

Company: Bilt Rewards

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You receive a small Java project for a credit-card rewards service with three failing unit tests: calculatesTriplePointsForRestaurants, returnsUnknownWhenMerchantCodeMissing, and aggregatesDailyPointsCorrectly. Without adding new tests, make minimal, well-justified code changes in up to three files so that all tests pass. Walk through your debugging process: reproducing failures, reading assertions and stack traces, isolating defects, and verifying no regressions. Then implement fixes such as correcting a category check for 'Restaurant', handling null/empty merchantCode safely, and resolving an off-by-one error in daily aggregation. Finally, explain how you would prevent future regressions (e.g., edge-case tests, input validation, and code review checklist).

Quick Answer: This question evaluates proficiency in debugging and maintaining a Java codebase with failing unit tests, testing competencies in unit testing, fault isolation, reading test assertions and stack traces, and verifying regression-free fixes.

|Home/Coding & Algorithms/Bilt Rewards
Bilt Rewards logo
Bilt Rewards
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
2
0

You receive a small Java project for a credit-card rewards service with three failing unit tests: calculatesTriplePointsForRestaurants, returnsUnknownWhenMerchantCodeMissing, and aggregatesDailyPointsCorrectly. Without adding new tests, make minimal, well-justified code changes in up to three files so that all tests pass. Walk through your debugging process: reproducing failures, reading assertions and stack traces, isolating defects, and verifying no regressions. Then implement fixes such as correcting a category check for 'Restaurant', handling null/empty merchantCode safely, and resolving an off-by-one error in daily aggregation. Finally, explain how you would prevent future regressions (e.g., edge-case tests, input validation, and code review checklist).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...