Job Opening for Tester of Web Apps at Moolya >>Could you spot this? This is intentional!

Testing on the Toilet: Only Verify Relevant Method Arguments

This article was adapted from a Google Testing on the Toilet (TotT) episode. You can download a printer-friendly version of this TotT episode and post it in your office.By Dillon BlyWhat makes this test fragile?@Test public void displayGreeting_showSpecialGreetingOnNewYearsDay() { fakeClock.setTime(NEW_YEARS_DAY); fakeUser.setName("Fake User”); userGreeter.displayGreeting(); // The test will fail if userGreeter.displayGreeting() didn’t call // mockUserPrompter.updatePrompt() with these exact arguments. verify(mockUserPrompter).updatePrompt( "Hi Fake User! Happy New Year!", TitleBar.of("2018-01-01"), PromptStyle.NORMAL);}The test specifies exact values for all arguments to mockUserPrompter. These arguments may need to be updated when the code under test is changed,...


Share |

Published By: Google Testing Blog - Tuesday, 26 June, 2018