Add Test suite support for JUnit 5 classes (#549)

* Add Test suite support for JUnit 5 classes

Added Gradle dependencies and updated lockfiles.

Updated SqlInegrationTestSuite to use new annotations.

Migrated one member class in SqlIntegrationTestSuite (CursorDaoTest)
to JUnit 5, and verified that the new Suite runner can handle a
mixture of JUnit 4 and 5 tests in one suite.

Note that Gradle tests that run TestSuites must choose JUnit 4.
Updated core/build.gradle and integration/build.gradle.
This commit is contained in:
Weimin Yu 2020-04-07 21:06:49 -04:00 committed by GitHub
parent 3dbc4e5d46
commit 5face3b2fe
37 changed files with 229 additions and 210 deletions

View file

@ -30,13 +30,10 @@ import google.registry.testing.FakeClock;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link Cursor}. */
@RunWith(JUnit4.class)
public class CursorDaoTest {
private final FakeClock fakeClock = new FakeClock();
@ -44,7 +41,7 @@ public class CursorDaoTest {
private final TestLogHandler logHandler = new TestLogHandler();
private final Logger loggerToIntercept = Logger.getLogger(CursorDao.class.getCanonicalName());
@Rule
@RegisterExtension
public final AppEngineRule appEngine =
AppEngineRule.builder().withDatastoreAndCloudSql().withClock(fakeClock).build();

View file

@ -27,9 +27,9 @@ import google.registry.schema.tmch.ClaimsListDaoTest;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
/**
* Groups all JPA entity tests in one suite for easy invocation. This suite is used for
@ -48,8 +48,8 @@ import org.junit.runners.Suite.SuiteClasses;
* database. Therefore this is not the right place for verifying backward data compatibility in
* end-to-end functional tests.
*/
@RunWith(Suite.class)
@SuiteClasses({
@RunWith(JUnitPlatform.class)
@SelectClasses({
ClaimsListDaoTest.class,
CursorDaoTest.class,
DomainBaseSqlTest.class,