From 2b503c1670d69446d2f5468f2f130bb20b8231f1 Mon Sep 17 00:00:00 2001 From: Vasiliy Zukanov Date: Wed, 12 Jun 2019 13:28:01 +0300 Subject: [PATCH] Small test code cleanup --- .../threadposters/FetchDataUseCaseTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sample/src/test/java/com/techyourchance/threadposters/FetchDataUseCaseTest.java b/sample/src/test/java/com/techyourchance/threadposters/FetchDataUseCaseTest.java index 9846c6d..bf2d39c 100755 --- a/sample/src/test/java/com/techyourchance/threadposters/FetchDataUseCaseTest.java +++ b/sample/src/test/java/com/techyourchance/threadposters/FetchDataUseCaseTest.java @@ -19,7 +19,7 @@ public class FetchDataUseCaseTest { private static final String TEST_DATA = "testData"; - private ThreadPostersTestDouble mThreadPostersTestDouble = new ThreadPostersTestDouble(); + private ThreadPostersTestDouble mThreadPostersTestDouble; private FakeDataFetcher mFakeDataFetcherMock; private FetchDataUseCase.Listener mListener1; @@ -30,6 +30,7 @@ public class FetchDataUseCaseTest { @Before public void setup() throws Exception { mFakeDataFetcherMock = mock(FakeDataFetcher.class); + mThreadPostersTestDouble = new ThreadPostersTestDouble(); SUT = new FetchDataUseCase( mFakeDataFetcherMock, @@ -59,7 +60,6 @@ public void fetchData_successNoListeners_completesWithoutErrors() throws Excepti public void fetchData_successMultipleListeners_notifiedWithCorrectData() throws Exception { // Arrange success(); - ArgumentCaptor ac = ArgumentCaptor.forClass(String.class); // Act SUT.registerListener(mListener1); SUT.registerListener(mListener2); @@ -70,11 +70,8 @@ public void fetchData_successMultipleListeners_notifiedWithCorrectData() throws // all side effects to be present mThreadPostersTestDouble.join(); - verify(mListener1).onDataFetched(ac.capture()); - verify(mListener2).onDataFetched(ac.capture()); - List dataList = ac.getAllValues(); - assertThat(dataList.get(0), is(TEST_DATA)); - assertThat(dataList.get(1), is(TEST_DATA)); + verify(mListener1).onDataFetched(TEST_DATA); + verify(mListener2).onDataFetched(TEST_DATA); } @Test