From c0fd4312038e7bfd35d63828c77240618ba22eee Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 3 Jan 2022 18:31:24 +0100 Subject: [PATCH] Don't use deprecated methods of Mockito [skip release] --- .../MockFieldsShouldBeResetBetweenTestMethodsTest.java | 8 ++++---- .../FailingOnPurposeBecauseIncorrectStubbingSyntax.java | 3 --- ...seBecauseWrongStubbingSyntaxInConfigurationMethod.java | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/mockitousage/testng/MockFieldsShouldBeResetBetweenTestMethodsTest.java b/src/test/java/org/mockitousage/testng/MockFieldsShouldBeResetBetweenTestMethodsTest.java index cc7d40a..0705408 100644 --- a/src/test/java/org/mockitousage/testng/MockFieldsShouldBeResetBetweenTestMethodsTest.java +++ b/src/test/java/org/mockitousage/testng/MockFieldsShouldBeResetBetweenTestMethodsTest.java @@ -16,8 +16,8 @@ import java.util.Observable; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; -import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -31,7 +31,7 @@ public class MockFieldsShouldBeResetBetweenTestMethodsTest { @Mock Observable will_be_nulled; @Test - public void behaviour_A_without_infection_from_behaviour_B() throws Exception { + public void behaviour_A_without_infection_from_behaviour_B() { // verify mock is clean assertThat(list.get(0)).isNull(); verify(list, never()).add(anyString()); @@ -44,7 +44,7 @@ public void behaviour_A_without_infection_from_behaviour_B() throws Exception { } @Test - public void behaviour_B_without_infection_from_behaviour_A() throws Exception { + public void behaviour_B_without_infection_from_behaviour_A() { // verify mock is clean assertThat(list.get(0)).isNull(); verify(list, never()).add(anyString()); @@ -57,7 +57,7 @@ public void behaviour_B_without_infection_from_behaviour_A() throws Exception { } @Test - public void dont_fail_when_reseting_null_field() throws Exception { + public void dont_fail_when_reseting_null_field() { will_be_nulled = null; } } diff --git a/src/test/java/org/mockitousage/testng/failuretests/FailingOnPurposeBecauseIncorrectStubbingSyntax.java b/src/test/java/org/mockitousage/testng/failuretests/FailingOnPurposeBecauseIncorrectStubbingSyntax.java index e118f75..b2068a2 100644 --- a/src/test/java/org/mockitousage/testng/failuretests/FailingOnPurposeBecauseIncorrectStubbingSyntax.java +++ b/src/test/java/org/mockitousage/testng/failuretests/FailingOnPurposeBecauseIncorrectStubbingSyntax.java @@ -6,9 +6,6 @@ import static org.mockito.ArgumentMatchers.anySet; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; - -import java.io.PrintStream; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.Listeners; diff --git a/src/test/java/org/mockitousage/testng/failuretests/FailingOnPurposeBecauseWrongStubbingSyntaxInConfigurationMethod.java b/src/test/java/org/mockitousage/testng/failuretests/FailingOnPurposeBecauseWrongStubbingSyntaxInConfigurationMethod.java index 83261d8..0f14c95 100644 --- a/src/test/java/org/mockitousage/testng/failuretests/FailingOnPurposeBecauseWrongStubbingSyntaxInConfigurationMethod.java +++ b/src/test/java/org/mockitousage/testng/failuretests/FailingOnPurposeBecauseWrongStubbingSyntaxInConfigurationMethod.java @@ -4,6 +4,8 @@ */ package org.mockitousage.testng.failuretests; +import static org.mockito.ArgumentMatchers.anyString; + import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; @@ -12,8 +14,6 @@ import java.util.List; -import static org.mockito.Matchers.anyString; - /** * Should fail. * @@ -32,7 +32,7 @@ public class FailingOnPurposeBecauseWrongStubbingSyntaxInConfigurationMethod { @Test - public void here_to_execute_the_config_method() throws Exception { + public void here_to_execute_the_config_method() { } }