From c50f16853bb5f94035ef8a858d53f7806e2e5307 Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Fri, 14 Jun 2019 13:37:32 -0400 Subject: [PATCH] Don't use @RunWith JUnit annotations on classes with no @Tests IntelliJ is complaining when this annotation is used on a base class that has no actual runnable tests itself. The solution is different for different classes depending on the existing pattern of where the @RunWith annotation is; for some, it's simplest to move the annotation down to the few extending classes that are missing it, whereas in others it's easiest just to annotate the base class as abstract. --- core/src/test/java/google/registry/model/EntityTestCase.java | 2 +- .../java/google/registry/model/ResourceCommandTestCase.java | 1 + .../java/google/registry/model/host/HostCommandTest.java | 1 + .../java/google/registry/model/registrar/RegistrarTest.java | 2 +- .../java/google/registry/rdap/RdapActionBaseTestCase.java | 5 +---- .../test/java/google/registry/rdap/RdapHelpActionTest.java | 3 +++ .../java/google/registry/rdap/RdapSearchActionTestCase.java | 2 +- .../test/java/google/registry/tmch/TmchActionTestCase.java | 2 +- .../ui/server/registrar/RegistrarSettingsActionTestCase.java | 5 +---- 9 files changed, 11 insertions(+), 12 deletions(-) diff --git a/core/src/test/java/google/registry/model/EntityTestCase.java b/core/src/test/java/google/registry/model/EntityTestCase.java index b822f9734..f6c436a85 100644 --- a/core/src/test/java/google/registry/model/EntityTestCase.java +++ b/core/src/test/java/google/registry/model/EntityTestCase.java @@ -48,7 +48,7 @@ import org.junit.runners.JUnit4; /** Base class of all unit tests for entities which are persisted to Datastore via Objectify. */ @RunWith(JUnit4.class) -public class EntityTestCase { +public abstract class EntityTestCase { @Rule public final AppEngineRule appEngine = AppEngineRule.builder() diff --git a/core/src/test/java/google/registry/model/ResourceCommandTestCase.java b/core/src/test/java/google/registry/model/ResourceCommandTestCase.java index 066430f30..aed5e9bc8 100644 --- a/core/src/test/java/google/registry/model/ResourceCommandTestCase.java +++ b/core/src/test/java/google/registry/model/ResourceCommandTestCase.java @@ -23,6 +23,7 @@ import google.registry.testing.EppLoader; /** Unit tests for {@code ResourceCommand}. */ public abstract class ResourceCommandTestCase extends EntityTestCase { + protected void doXmlRoundtripTest(String inputFilename, String... ignoredPaths) throws Exception { EppLoader eppLoader = new EppLoader(this, inputFilename); diff --git a/core/src/test/java/google/registry/model/host/HostCommandTest.java b/core/src/test/java/google/registry/model/host/HostCommandTest.java index dc96866ac..d34cfd66e 100644 --- a/core/src/test/java/google/registry/model/host/HostCommandTest.java +++ b/core/src/test/java/google/registry/model/host/HostCommandTest.java @@ -19,6 +19,7 @@ import org.junit.Test; /** Test xml roundtripping of commands. */ public class HostCommandTest extends ResourceCommandTestCase { + @Test public void testCreate() throws Exception { doXmlRoundtripTest("host_create.xml"); diff --git a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java index 67a28c541..b0e15c5f9 100644 --- a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java +++ b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java @@ -46,7 +46,7 @@ import org.joda.money.CurrencyUnit; import org.junit.Before; import org.junit.Test; -/** Unit tests for {@link Registrar}. */ + /** Unit tests for {@link Registrar}. */ public class RegistrarTest extends EntityTestCase { private Registrar registrar; private RegistrarContact abuseAdminContact; diff --git a/core/src/test/java/google/registry/rdap/RdapActionBaseTestCase.java b/core/src/test/java/google/registry/rdap/RdapActionBaseTestCase.java index 5bad3c2f7..b0ba83585 100644 --- a/core/src/test/java/google/registry/rdap/RdapActionBaseTestCase.java +++ b/core/src/test/java/google/registry/rdap/RdapActionBaseTestCase.java @@ -41,12 +41,9 @@ import java.util.Optional; import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** Common unit test code for actions inheriting {@link RdapActionBase}. */ -@RunWith(JUnit4.class) -public class RdapActionBaseTestCase { +public abstract class RdapActionBaseTestCase { @Rule public final AppEngineRule appEngine = AppEngineRule.builder() diff --git a/core/src/test/java/google/registry/rdap/RdapHelpActionTest.java b/core/src/test/java/google/registry/rdap/RdapHelpActionTest.java index ed858fd06..a23591b49 100644 --- a/core/src/test/java/google/registry/rdap/RdapHelpActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapHelpActionTest.java @@ -24,8 +24,11 @@ import google.registry.rdap.RdapMetrics.WildcardType; import google.registry.rdap.RdapSearchResults.IncompletenessWarningType; import google.registry.request.Action; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** Unit tests for {@link RdapHelpAction}. */ +@RunWith(JUnit4.class) public class RdapHelpActionTest extends RdapActionBaseTestCase { public RdapHelpActionTest() { diff --git a/core/src/test/java/google/registry/rdap/RdapSearchActionTestCase.java b/core/src/test/java/google/registry/rdap/RdapSearchActionTestCase.java index 7519462a9..e06b1f52a 100644 --- a/core/src/test/java/google/registry/rdap/RdapSearchActionTestCase.java +++ b/core/src/test/java/google/registry/rdap/RdapSearchActionTestCase.java @@ -27,7 +27,7 @@ import java.util.Optional; import org.junit.Before; /** Common unit test code for actions inheriting {@link RdapSearchActionBase}. */ -public class RdapSearchActionTestCase +public abstract class RdapSearchActionTestCase extends RdapActionBaseTestCase { protected RdapSearchActionTestCase(Class rdapActionClass) { diff --git a/core/src/test/java/google/registry/tmch/TmchActionTestCase.java b/core/src/test/java/google/registry/tmch/TmchActionTestCase.java index 97308c24e..7f7444dea 100644 --- a/core/src/test/java/google/registry/tmch/TmchActionTestCase.java +++ b/core/src/test/java/google/registry/tmch/TmchActionTestCase.java @@ -36,7 +36,7 @@ import org.mockito.junit.MockitoRule; /** Common code for unit tests of classes that extend {@link Marksdb}. */ @RunWith(JUnit4.class) -public class TmchActionTestCase { +public abstract class TmchActionTestCase { static final String MARKSDB_LOGIN_AND_PASSWORD = "lolcat:attack"; static final String MARKSDB_URL = "http://127.0.0.1/love"; diff --git a/core/src/test/java/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java b/core/src/test/java/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java index 267e79c80..05f9eae86 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java +++ b/core/src/test/java/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java @@ -59,16 +59,13 @@ import org.joda.time.DateTime; import org.junit.After; import org.junit.Before; import org.junit.Rule; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; /** Base class for tests using {@link RegistrarSettingsAction}. */ -@RunWith(JUnit4.class) -public class RegistrarSettingsActionTestCase { +public abstract class RegistrarSettingsActionTestCase { static final String CLIENT_ID = "TheRegistrar";