Skip to content

Commit

Permalink
Update unit test verification methods to use verifyNoInteractions
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiangollob committed Nov 26, 2024
1 parent 455ca92 commit 5c77520
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
if: success() || failure()
with:
name: Unit Tests
path: catroid/build/test-results/testCatroidDebugUnitTest/*.xml
path: catroid/build/test-results/**/*TEST*.xml
reporter: java-junit

- name: Upload Unit Test Reports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.verifyZeroInteractions;

@RunWith(Parameterized.class)
public class CompositeBrickTest {
Expand Down Expand Up @@ -115,7 +115,7 @@ public void testSetParents() {
compositeBrick.setParent(mockParent);

verify(compositeBrick.getNestedBricks().get(0)).setParent(compositeBrick);
verifyZeroInteractions(mockParent);
verifyNoInteractions(mockParent);

assertSame(compositeBrick, compositeEndBrick.getParent());
}
Expand All @@ -126,7 +126,7 @@ public void testGetParentListFromCompositeStartBrick() {
compositeBrick.setParent(mockParent);

List<Brick> parentList = compositeBrick.getDragAndDropTargetList();
verifyZeroInteractions(mockParent);
verifyNoInteractions(mockParent);

assertSame(compositeBrick.getNestedBricks(), parentList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.verifyZeroInteractions;

@RunWith(Parameterized.class)
public class CompositeBrickWithSecondaryListTest {
Expand Down Expand Up @@ -116,7 +116,7 @@ public void testSetParents() {
compositeBrick.setParent(mockParent);

verify(compositeBrick.getNestedBricks().get(0)).setParent(compositeBrick);
verifyZeroInteractions(mockParent);
verifyNoInteractions(mockParent);

assertSame(compositeBrick, compositeMiddleBrick.getParent());

Expand All @@ -130,7 +130,7 @@ public void testGetParentListFromCompositeStartBrick() {
compositeBrick.setParent(mockParent);

List<Brick> parentList = compositeBrick.getDragAndDropTargetList();
verifyZeroInteractions(mockParent);
verifyNoInteractions(mockParent);

assertSame(compositeBrick.getNestedBricks(), parentList);
}
Expand All @@ -153,7 +153,7 @@ public void testGetParentListFromCompositeMiddleBrick() {
compositeBrick.setParent(mockParent);

List<Brick> parentList = compositeMiddleBrick.getDragAndDropTargetList();
verifyZeroInteractions(mockParent);
verifyNoInteractions(mockParent);

assertSame(compositeBrick.getSecondaryNestedBricks(), parentList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.internal.verification.VerificationModeFactory.times;
import static org.powermock.api.mockito.PowerMockito.verifyZeroInteractions;

@RunWith(JUnit4.class)
public class JobHandlerEventTest {
Expand All @@ -60,7 +60,7 @@ public void testReceivedOnDownloadStartedEvent() {

verify(jobMock, times(1)).getJobID();
verifyNoMoreInteractions(jobMock);
verifyZeroInteractions(convertCallbackMock);
verifyNoInteractions(convertCallbackMock);
}

@Test
Expand All @@ -72,7 +72,7 @@ public void testReceivedOnDownloadFinishedEvent() {

verify(jobMock, times(1)).getJobID();
verifyNoMoreInteractions(jobMock);
verifyZeroInteractions(convertCallbackMock);
verifyNoInteractions(convertCallbackMock);
}

@Test
Expand All @@ -84,7 +84,7 @@ public void testReceivedOnUserCanceledDownloadEvent() {

verify(jobMock, times(1)).getJobID();
verifyNoMoreInteractions(jobMock);
verifyZeroInteractions(convertCallbackMock);
verifyNoInteractions(convertCallbackMock);
}

@Test
Expand All @@ -95,7 +95,7 @@ public void testReceivedOnUserCanceledConversionEvent() {

verify(jobMock, times(1)).getJobID();
verifyNoMoreInteractions(jobMock);
verifyZeroInteractions(convertCallbackMock);
verifyNoInteractions(convertCallbackMock);
}

@Test
Expand All @@ -107,6 +107,6 @@ public void testReceivedOnJobScheduledEvent() {

verify(jobMock, times(1)).getJobID();
verifyNoMoreInteractions(jobMock);
verifyZeroInteractions(convertCallbackMock);
verifyNoInteractions(convertCallbackMock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.internal.verification.VerificationModeFactory.atLeast;
import static org.powermock.api.mockito.PowerMockito.verifyZeroInteractions;

@RunWith(Parameterized.class)
public class JobHandlerIgnoreMessageInSpecificStateTest {
Expand Down Expand Up @@ -99,7 +99,7 @@ public void setUp() {
@Test
public void testIgnoreMessage() {
jobHandler.onJobMessage(message);
verifyZeroInteractions(convertCallbackMock);
verifyNoInteractions(convertCallbackMock);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.verifyZeroInteractions;

@RunWith(Parameterized.class)
public class JobHandlerJobStateTest {
Expand Down Expand Up @@ -101,6 +101,6 @@ public void testIsJobInProgressWrapperCalled() {
assertEquals(jobState.isInProgress(), jobHandler.isInProgress());
verify(jobSpy, times(1)).isInProgress();
verifyNoMoreInteractions(jobSpy);
verifyZeroInteractions(convertCallbackMock);
verifyNoInteractions(convertCallbackMock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import static junit.framework.Assert.assertEquals;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.verifyZeroInteractions;

public class JobHandlerJobWrapperTest {
private Client.ConvertCallback convertCallbackMock;
Expand All @@ -52,6 +52,6 @@ public void testIsGetJobIDWrapperCalled() {
long expectedJobID = 42;
when(jobMock.getJobID()).thenReturn(expectedJobID);
assertEquals(expectedJobID, jobHandler.getJobID());
verifyZeroInteractions(convertCallbackMock);
verifyNoInteractions(convertCallbackMock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
import static junit.framework.Assert.assertTrue;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.verifyZeroInteractions;

@RunWith(MockitoJUnitRunner.class)
public class VisualPlacementTouchListenerTest {
Expand Down Expand Up @@ -86,7 +86,7 @@ public void testOnTouchReturnFalse() {
when(firstEvent.getPointerId(0)).thenReturn(1);
boolean returnValue = listener.onTouch(imageView, firstEvent, coordinateInterface);
assertFalse(returnValue);
verifyZeroInteractions(coordinateInterface);
verifyNoInteractions(coordinateInterface);
}

@Test
Expand Down

0 comments on commit 5c77520

Please sign in to comment.