PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Other / Miscellaneous/Meta

Design unit tests for grid navigation

Last updated: Mar 29, 2026

Quick Overview

This question evaluates unit test design, mocking/stubbing of external APIs, deterministic simulation, and correctness of grid-navigation controller logic under edge cases, loops, performance limits, and API error behaviors.

  • medium
  • Meta
  • Other / Miscellaneous
  • Software Engineer

Design unit tests for grid navigation

Company: Meta

Role: Software Engineer

Category: Other / Miscellaneous

Difficulty: medium

Interview Round: Technical Screen

Propose a comprehensive set of unit tests for the mouse-maze controller described above. Include tests for: single-cell maze; unreachable cheese; narrow corridors and cul-de-sacs; loops/cycles; large open spaces; obstacle directly ahead; repeated visits and backtracking correctness; multiple cheeses (ensure the first found is returned); performance and stack-depth limits; and API error behavior (e.g., move() throwing). Describe how to stub/simulate the interface deterministically.

Quick Answer: This question evaluates unit test design, mocking/stubbing of external APIs, deterministic simulation, and correctness of grid-navigation controller logic under edge cases, loops, performance limits, and API error behaviors.

Related Interview Questions

  • Implement, Debug, and Optimize a React Table - Meta (hard)
Meta logo
Meta
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Other / Miscellaneous
1
0

Mouse-Maze Controller: Design a Comprehensive Unit Test Suite

Context (assumptions to make the task self-contained)

Assume we are testing a controller that navigates a grid-based maze to find cheese. The controller drives an abstract Maze API and must return the first cheese it finds according to a deterministic neighbor-order policy. Multiple cheeses may exist; some may be unreachable.

  • Grid representation: rectangular grid with walls and open cells.
  • Start position: a single cell where the mouse begins.
  • Cheese: one or more target cells; reaching any one ends the search successfully.
  • Deterministic neighbor exploration order: Up, Right, Down, Left (URDL), unless otherwise specified.
  • The Maze API can signal walls/valid moves and may throw errors on move attempts.
  • Controller output: either a path (sequence of directions) to a found cheese, or a NotFound/Failure result.

You may minimally adjust the exact API shape but keep behavior semantically equivalent to the above.

Task

Propose a comprehensive set of unit tests for the mouse-maze controller. Include tests for:

  1. Single-cell maze
  2. Unreachable cheese
  3. Narrow corridors and cul-de-sacs
  4. Loops/cycles
  5. Large open spaces
  6. Obstacle directly ahead
  7. Repeated visits and backtracking correctness
  8. Multiple cheeses (ensure the first found is returned)
  9. Performance and stack-depth limits
  10. API error behavior (e.g., move() throwing)

Also describe how to stub/simulate the Maze API deterministically to support these tests.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Other / Miscellaneous•More Meta•More Software Engineer•Meta Software Engineer•Meta Other / Miscellaneous•Software Engineer Other / Miscellaneous
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.