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.
This commit is contained in:
Ben McIlwain 2019-06-14 13:37:32 -04:00 committed by Ben McIlwain
parent d3f0d34e2b
commit c50f16853b
9 changed files with 11 additions and 12 deletions

View file

@ -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()

View file

@ -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);

View file

@ -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");

View file

@ -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;

View file

@ -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<A extends RdapActionBase> {
public abstract class RdapActionBaseTestCase<A extends RdapActionBase> {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()

View file

@ -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<RdapHelpAction> {
public RdapHelpActionTest() {

View file

@ -27,7 +27,7 @@ import java.util.Optional;
import org.junit.Before;
/** Common unit test code for actions inheriting {@link RdapSearchActionBase}. */
public class RdapSearchActionTestCase<A extends RdapSearchActionBase>
public abstract class RdapSearchActionTestCase<A extends RdapSearchActionBase>
extends RdapActionBaseTestCase<A> {
protected RdapSearchActionTestCase(Class<A> rdapActionClass) {

View file

@ -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";

View file

@ -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";