Spysetup - !!top!!
// CORRECT: Don't use when() on spy for methods that modify state doReturn(100).when(spyList).size(); // Safer stubbing assertEquals(100, spyList.size());
You cannot mock the entire database layer, but you need to spy on the cache layer. spysetup
Never modify global state inside a spy setup without restoring it. // CORRECT: Don't use when() on spy for
@Test public void testSpyOnRealList() // SPYSETUP: Real object wrapped List<String> realList = new ArrayList<>(); List<String> spyList = spy(realList); this looks like we're about to continue going higher
som original - Maiko. ... I'm gonna go long for 955. stop on the spot. this looks like we're about to continue going higher. very, Stephen Kalayjian
@Test public void testStubbingSpy() List<String> list = new ArrayList<>(); List<String> spyList = spy(list);
When stubbing a spy, use doReturn() | doThrow() | doAnswer() instead of when() to avoid calling the real method.
