Hadoop MapReduce jobs have a unique code architecture that follows a specific template with specific constructs. This architecture raises interesting issues when doing test-driven development (TDD) and writing unit tests. This is a real-world example using MRUnit, Mockito, and PowerMock. I will touch upon 1) using MRUnit to write JUnit tests for hadoop MR applications, 2) using PowerMock & Mockito to mock static methods, 3) mocking-out business-logic contained in another class, 4) verifying that mocked-out business logic was called (or not) 5) testing counters, 6) testing statements in a log4j conditional block, and 7) handling exceptions in tests. I’m assuming the reader is already familiar with JUnit 4.