Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to JUnit 5 #2771

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c0e9f26
Migrate tests to JUnit5 (work in progress)
ljacqu Apr 26, 2019
f96f838
Fix some of the test failures
ljacqu Apr 27, 2019
2e0f0cc
Fix ConsoleLoggerTest breaking subsequent tests
ljacqu Apr 27, 2019
e9f7d95
Revert to TemporaryFolder for test using Junit-vintage runner
ljacqu Apr 27, 2019
16ef0ce
Migrate parameterized tests to JUnit5
ljacqu Apr 27, 2019
cdec468
Migrate DelayedInjectionRunner to JUnit 5 extension (work in progress)
ljacqu May 1, 2019
5f5fb0c
Merge remote-tracking branch 'origin/master' into junit5-migration
ljacqu May 2, 2019
82200d4
Merge remote-tracking branch 'origin/master' into junit5-migration
ljacqu Oct 8, 2019
1873a21
Junit5 migration: fix failing test & migrate new tests
ljacqu Oct 8, 2019
8060b11
Merge remote-tracking branch 'origin/master' into junit5-migration
ljacqu Nov 6, 2019
85a2f13
Change Junit5 tests to package-private visibility
ljacqu Nov 7, 2019
74a104e
Use 'assertThat' from Hamcrest instead of Junit4
ljacqu Nov 7, 2019
31dcb38
Merge branch 'master' of https://github.com/AuthMe/AuthMeReloaded int…
ljacqu Mar 30, 2020
ebd8ff8
Merge remote-tracking branch 'origin/junit5-migration' into junit5-mi…
ljacqu Mar 30, 2020
d12f304
update
ljacqu May 2, 2020
210f867
Merge remote-tracking branch 'origin/master' into junit5-migration
ljacqu Apr 19, 2021
4a3ee42
Migrate BukkitServiceTest and CommandManagerTest to JUnit 5
ljacqu Apr 19, 2021
cbfd884
Migrate last tests to JUnit 5
ljacqu Apr 19, 2021
17d5691
Replace assumption/assertTrue imports from Junit4 and remove JUnit vi…
ljacqu Apr 19, 2021
68f1322
Merge remote-tracking branch 'origin/master' into junit5-migration
ljacqu Jan 30, 2022
d3a5501
Merge remote-tracking branch 'origin/master' into junit5-migration
ljacqu Aug 23, 2023
ee42437
Merge branch 'master' into junit5-migration
ljacqu Dec 20, 2023
67ec218
Update test dependencies / remove unnecessary public modifiers
ljacqu Dec 20, 2023
13087f7
Replace "InjectDelayed" extension everywhere with Mockito extension
ljacqu Dec 20, 2023
6161d95
Keep Mockito versions in sync; small fixes after JUnit 5 migration
ljacqu Dec 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrate parameterized tests to JUnit5
ljacqu committed Apr 27, 2019
commit 16ef0cefc62217da250d21dbda0f50ed45e3baf1
12 changes: 4 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -868,16 +868,12 @@
<scope>test</scope>
<version>5.4.2</version>
</dependency>
<!--<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>5.4.2</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
<version>5.4.2</version>
</dependency>-->
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package fr.xephi.authme.data.limbo;

import org.bukkit.entity.Player;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import static fr.xephi.authme.data.limbo.LimboPlayer.DEFAULT_FLY_SPEED;
import static fr.xephi.authme.data.limbo.LimboPlayer.DEFAULT_WALK_SPEED;
@@ -22,17 +20,11 @@
/**
* Test for {@link WalkFlySpeedRestoreType}.
*/
@RunWith(Parameterized.class)
public class WalkFlySpeedRestoreTypeTest {
class WalkFlySpeedRestoreTypeTest {

private final TestParameters parameters;

public WalkFlySpeedRestoreTypeTest(TestParameters parameters) {
this.parameters = parameters;
}

@Test
public void shouldRestoreToExpectedValue() {
@ParameterizedTest
@MethodSource("buildParams")
void shouldRestoreToExpectedValue(TestParameters parameters) {
// given
LimboPlayer limbo = mock(LimboPlayer.class);
given(limbo.getWalkSpeed()).willReturn(parameters.givenLimboWalkSpeed);
@@ -50,10 +42,9 @@ public void shouldRestoreToExpectedValue() {
verify(player).setWalkSpeed(parameters.expectedWalkSpeed);
verify(player).setFlySpeed(parameters.expectedFlySpeed);
}

@Parameterized.Parameters(name = "{0}")
public static List<Object[]> buildParams() {
List<TestParameters> parameters = Arrays.asList(

private static List<TestParameters> buildParams() {
return Arrays.asList(
create(RESTORE).withLimbo(0.1f, 0.4f).withPlayer(0.3f, 0.9f).expect(0.1f, 0.4f),
create(RESTORE).withLimbo(0.9f, 0.2f).withPlayer(0.3f, 0.0f).expect(0.9f, 0.2f),
create(MAX_RESTORE).withLimbo(0.3f, 0.8f).withPlayer(0.5f, 0.2f).expect(0.5f, 0.8f),
@@ -62,9 +53,6 @@ public static List<Object[]> buildParams() {
create(RESTORE_NO_ZERO).withLimbo(0.0f, 0.005f).withPlayer(0.4f, 0.8f).expect(DEFAULT_WALK_SPEED, DEFAULT_FLY_SPEED),
create(DEFAULT).withLimbo(0.1f, 0.7f).withPlayer(0.4f, 0.0f).expect(DEFAULT_WALK_SPEED, DEFAULT_FLY_SPEED)
);

// Convert List<TestParameters> to List<Object[]>
return parameters.stream().map(p -> new Object[]{p}).collect(Collectors.toList());
}

private static TestParameters create(WalkFlySpeedRestoreType testedType) {
Original file line number Diff line number Diff line change
@@ -5,10 +5,9 @@
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.security.crypts.HashedPassword;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

@@ -44,35 +43,20 @@
* which is set to create additional mocks on demand for Statement and ResultSet objects.
* This test ensures that all such objects that are created will be closed again by
* keeping a list of mocks ({@link #closeables}) and then verifying that all have been
* closed ({@link #verifyHaveMocksBeenClosed()}).
* closed ({@link #verifyHaveMocksBeenClosed(Method)}).
*/
@RunWith(Parameterized.class)
public abstract class AbstractResourceClosingTest {

/** Collection of values to use to call methods with the parameters they expect. */
private static final Map<Class<?>, Object> PARAM_VALUES = getDefaultParameters();

/** The DataSource method to test. */
private Method method;

/** Keeps track of the closeables which are created during the tested call. */
private List<AutoCloseable> closeables = new ArrayList<>();

private boolean hasCreatedConnection = false;

/**
* Constructor for the test instance verifying the given method.
*
* @param method The DataSource method to test
* @param name The name of the method
*/
public AbstractResourceClosingTest(Method method, String name) {
// Note ljacqu 20160227: The name parameter is necessary as we pass it from the @Parameters method;
// we use the method name in the annotation to name the test sensibly
this.method = method;
}

@BeforeClass
@BeforeAll
public static void initializeLogger() {
TestHelper.setupLogger();
}
@@ -81,18 +65,21 @@ public static void initializeLogger() {
* The actual test -- executes the method given through the constructor and then verifies that all
* AutoCloseable mocks it constructed have been closed.
*/
@Test
public void shouldCloseResources() throws IllegalAccessException, InvocationTargetException {
@ParameterizedTest(name = "{1}")
@MethodSource("createParameters")
// Note ljacqu 20160227: The name parameter is necessary as we pass it from the arguments source method;
// we use the method name in the annotation to name the test sensibly
public void shouldCloseResources(Method method, String name) throws IllegalAccessException, InvocationTargetException {
method.invoke(getObjectUnderTest(), buildParamListForMethod(method));
verifyHaveMocksBeenClosed();
verifyHaveMocksBeenClosed(method);
}

protected abstract Object getObjectUnderTest();

/**
* Verify that all AutoCloseables that have been created during the method execution have been closed.
*/
private void verifyHaveMocksBeenClosed() {
private void verifyHaveMocksBeenClosed(Method method) {
if (closeables.isEmpty()) {
System.out.println("Note: detected no AutoCloseables for method '" + method.getName() + "'");
}
@@ -202,27 +189,21 @@ protected Connection initConnection() {

/* Create Answer that returns a PreparedStatement mock. */
private Answer<PreparedStatement> preparedStatementAnswer() {
return new Answer<PreparedStatement>() {
@Override
public PreparedStatement answer(InvocationOnMock invocation) throws SQLException {
PreparedStatement pst = mock(PreparedStatement.class);
closeables.add(pst);
given(pst.executeQuery()).willAnswer(resultSetAnswer());
given(pst.executeQuery(anyString())).willAnswer(resultSetAnswer());
return pst;
}
return invocation -> {
PreparedStatement pst = mock(PreparedStatement.class);
closeables.add(pst);
given(pst.executeQuery()).willAnswer(resultSetAnswer());
given(pst.executeQuery(anyString())).willAnswer(resultSetAnswer());
return pst;
};
}

/* Create Answer that returns a ResultSet mock. */
private Answer<ResultSet> resultSetAnswer() throws SQLException {
return new Answer<ResultSet>() {
@Override
public ResultSet answer(InvocationOnMock invocation) throws Throwable {
ResultSet rs = initResultSet();
closeables.add(rs);
return rs;
}
private Answer<ResultSet> resultSetAnswer() {
return invocation -> {
ResultSet rs = initResultSet();
closeables.add(rs);
return rs;
};
}

Original file line number Diff line number Diff line change
@@ -3,8 +3,7 @@
import com.google.common.collect.ImmutableSet;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.settings.Settings;
import org.junit.BeforeClass;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.BeforeAll;

import java.lang.reflect.Method;
import java.sql.Connection;
@@ -25,11 +24,7 @@ public abstract class AbstractSqlDataSourceResourceClosingTest extends AbstractR

private static Settings settings;

AbstractSqlDataSourceResourceClosingTest(Method method, String name) {
super(method, name);
}

@BeforeClass
@BeforeAll
public static void initializeSettings() {
settings = mock(Settings.class);
TestHelper.returnDefaultsForAllProperties(settings);
@@ -52,8 +47,7 @@ protected DataSource getObjectUnderTest() {
*
* @return Test parameters
*/
@Parameterized.Parameters(name = "{1}")
public static Collection<Object[]> data() {
public static Collection<Object[]> createParameters() {
List<Method> methods = getDataSourceMethods();
List<Object[]> data = new ArrayList<>();
for (Method method : methods) {
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
import fr.xephi.authme.datasource.mysqlextensions.MySqlExtensionsFactory;
import fr.xephi.authme.settings.Settings;

import java.lang.reflect.Method;
import java.sql.Connection;

import static org.mockito.ArgumentMatchers.any;
@@ -17,10 +16,6 @@
*/
public class MySqlResourceClosingTest extends AbstractSqlDataSourceResourceClosingTest {

public MySqlResourceClosingTest(Method method, String name) {
super(method, name);
}

@Override
protected DataSource createDataSource(Settings settings, Connection connection) throws Exception {
HikariDataSource hikariDataSource = mock(HikariDataSource.class);
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
import fr.xephi.authme.datasource.mysqlextensions.MySqlExtensionsFactory;
import fr.xephi.authme.settings.Settings;

import java.lang.reflect.Method;
import java.sql.Connection;

import static org.mockito.ArgumentMatchers.any;
@@ -17,10 +16,6 @@
*/
public class PostgreSqlResourceClosingTest extends AbstractSqlDataSourceResourceClosingTest {

public PostgreSqlResourceClosingTest(Method method, String name) {
super(method, name);
}

@Override
protected DataSource createDataSource(Settings settings, Connection connection) throws Exception {
HikariDataSource hikariDataSource = mock(HikariDataSource.class);
@@ -29,5 +24,4 @@ protected DataSource createDataSource(Settings settings, Connection connection)
given(extensionsFactory.buildExtension(any(Columns.class))).willReturn(mock(MySqlExtension.class));
return new PostgreSqlDataSource(settings, hikariDataSource, extensionsFactory);
}

}
Original file line number Diff line number Diff line change
@@ -2,21 +2,15 @@

import fr.xephi.authme.settings.Settings;

import java.lang.reflect.Method;
import java.sql.Connection;

/**
* Resource closing test for {@link SQLite}.
*/
public class SQLiteResourceClosingTest extends AbstractSqlDataSourceResourceClosingTest {

public SQLiteResourceClosingTest(Method method, String name) {
super(method, name);
}

@Override
protected DataSource createDataSource(Settings settings, Connection connection) throws Exception {
protected DataSource createDataSource(Settings settings, Connection connection) {
return new SQLite(settings, null, connection);
}

}
Original file line number Diff line number Diff line change
@@ -4,10 +4,8 @@
import fr.xephi.authme.datasource.AbstractResourceClosingTest;
import fr.xephi.authme.datasource.Columns;
import fr.xephi.authme.settings.Settings;
import org.junit.BeforeClass;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.BeforeAll;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.List;
@@ -23,11 +21,7 @@ public abstract class AbstractMySqlExtensionResourceClosingTest extends Abstract
private static Settings settings;
private static Columns columns;

public AbstractMySqlExtensionResourceClosingTest(Method method, String name) {
super(method, name);
}

@BeforeClass
@BeforeAll
public static void initSettings() {
settings = mock(Settings.class);
TestHelper.returnDefaultsForAllProperties(settings);
@@ -41,7 +35,6 @@ protected MySqlExtension getObjectUnderTest() {

protected abstract MySqlExtension createExtension(Settings settings, Columns columns);

@Parameterized.Parameters(name = "{1}")
public static List<Object[]> createParameters() {
return Arrays.stream(MySqlExtension.class.getDeclaredMethods())
.filter(m -> Modifier.isPublic(m.getModifiers()))
Original file line number Diff line number Diff line change
@@ -3,17 +3,11 @@
import fr.xephi.authme.datasource.Columns;
import fr.xephi.authme.settings.Settings;

import java.lang.reflect.Method;

/**
* Resource closing test for {@link Ipb4Extension}.
*/
public class Ipb4ExtensionResourceClosingTest extends AbstractMySqlExtensionResourceClosingTest {

public Ipb4ExtensionResourceClosingTest(Method method, String name) {
super(method, name);
}

@Override
protected MySqlExtension createExtension(Settings settings, Columns columns) {
return new Ipb4Extension(settings, columns);
Original file line number Diff line number Diff line change
@@ -3,17 +3,11 @@
import fr.xephi.authme.datasource.Columns;
import fr.xephi.authme.settings.Settings;

import java.lang.reflect.Method;

/**
* Resource closing test for {@link PhpBbExtension}.
*/
public class PhpBbExtensionResourceClosingTest extends AbstractMySqlExtensionResourceClosingTest {

public PhpBbExtensionResourceClosingTest(Method method, String name) {
super(method, name);
}

@Override
protected MySqlExtension createExtension(Settings settings, Columns columns) {
return new PhpBbExtension(settings, columns);
Original file line number Diff line number Diff line change
@@ -3,17 +3,11 @@
import fr.xephi.authme.datasource.Columns;
import fr.xephi.authme.settings.Settings;

import java.lang.reflect.Method;

/**
* Resource closing test for {@link WordpressExtension}.
*/
public class WordpressExtensionResourceClosingTest extends AbstractMySqlExtensionResourceClosingTest {

public WordpressExtensionResourceClosingTest(Method method, String name) {
super(method, name);
}

@Override
protected MySqlExtension createExtension(Settings settings, Columns columns) {
return new WordpressExtension(settings, columns);
Original file line number Diff line number Diff line change
@@ -3,17 +3,11 @@
import fr.xephi.authme.datasource.Columns;
import fr.xephi.authme.settings.Settings;

import java.lang.reflect.Method;

/**
* Resource closing test for {@link XfBcryptExtension}.
*/
public class XfBcryptExtensionResourceClosingTest extends AbstractMySqlExtensionResourceClosingTest {

public XfBcryptExtensionResourceClosingTest(Method method, String name) {
super(method, name);
}

@Override
protected MySqlExtension createExtension(Settings settings, Columns columns) {
return new XfBcryptExtension(settings, columns);
Original file line number Diff line number Diff line change
@@ -5,9 +5,8 @@
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import fr.xephi.authme.TestHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.io.File;
import java.util.ArrayList;
@@ -24,8 +23,7 @@
* Checks that the entries in messages_xx.yml files have the {@link MessageKey#getTags() placeholders}
* that are defined for the given message.
*/
@RunWith(Parameterized.class)
public class MessageFilePlaceholderTest {
class MessageFilePlaceholderTest {

/** Path in the resources folder where the message files are located. */
private static final String MESSAGES_FOLDER = "/messages/";
@@ -39,17 +37,10 @@ public class MessageFilePlaceholderTest {
.putAll(MessageKey.MAX_REGISTER_EXCEEDED, "%max_acc", "%reg_count", "%reg_names")
.build();

private File messagesFile;
private String messagesFilename;

// Note ljacqu 20170506: We pass the file name separately so we can reference it for the name in @Parameters
public MessageFilePlaceholderTest(File messagesFile, String name) {
this.messagesFile = messagesFile;
this.messagesFilename = name;
}

@Test
public void shouldHaveAllPlaceholders() {
// Note ljacqu 20170506: We pass the file name separately so we can use it as the test name
@ParameterizedTest(name = "{1}")
@MethodSource("buildParams")
void shouldHaveAllPlaceholders(File messagesFile, String messagesFilename) {
// given
PropertyReader reader = new YamlFileReader(messagesFile);
List<String> errors = new ArrayList<>(0);
@@ -78,8 +69,7 @@ private List<String> findMissingTags(MessageKey key, PropertyReader reader) {
return Collections.emptyList();
}

@Parameterized.Parameters(name = "{1}")
public static List<Object[]> buildParams() {
private static List<Object[]> buildParams() {
File folder = TestHelper.getJarFile(MESSAGES_FOLDER);

List<Object[]> messageFiles = Arrays.stream(listFilesOrThrow(folder))
Original file line number Diff line number Diff line change
@@ -21,13 +21,14 @@
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicesManager;
import org.junit.AssumptionViolatedException;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;
@@ -50,35 +51,29 @@
/**
* Tests the initialization of {@link PermissionHandler} in {@link PermissionsManager}.
*/
@RunWith(Parameterized.class)
public class PermissionsManagerInitializationTest {

@Parameterized.Parameter(0)
public PermissionsSystemType permissionsSystemType;
@Parameterized.Parameter(1)
public Class<?> expectedHandlerType;
class PermissionsManagerInitializationTest {

private Settings settings = mock(Settings.class);
private ServicesManager servicesManager = mock(ServicesManager.class);
private Server server = mock(Server.class);
private PluginManager pluginManager = mock(PluginManager.class);
private PermissionsManager permissionsManager = new PermissionsManager(server, pluginManager, settings);

@BeforeClass
public static void setUpLogger() {
@BeforeAll
static void setUpLogger() {
TestHelper.setRealLogger();
}

@Before
public void setUp() {
@BeforeEach
void setUp() {
ReflectionTestUtils.setField(Bukkit.class, null, "server", server);
given(server.getServicesManager()).willReturn(servicesManager);
}

@Test
public void shouldInitializeHandler() {
@ParamTest
void shouldInitializeHandler(PermissionsSystemType permissionsSystemType, Class<?> expectedHandlerType) {
// given
setUpForPermissionSystemTest();
setUpForPermissionSystemTest(permissionsSystemType);
given(settings.getProperty(PluginSettings.FORCE_VAULT_HOOK)).willReturn(false);
Plugin plugin = mock(Plugin.class);
given(plugin.isEnabled()).willReturn(true);
@@ -93,8 +88,8 @@ public void shouldInitializeHandler() {
assertThat(handler.getPermissionSystem(), equalTo(permissionsSystemType));
}

@Test
public void shouldInitializeToVaultIfSoConfigured() {
@ParamTest
void shouldInitializeToVaultIfSoConfigured(PermissionsSystemType permissionsSystemType, Class<?> expectedHandlerType) {
// given
setUpForVault();
given(settings.getProperty(PluginSettings.FORCE_VAULT_HOOK)).willReturn(true);
@@ -111,8 +106,8 @@ public void shouldInitializeToVaultIfSoConfigured() {
verify(pluginManager, only()).getPlugin(VAULT.getPluginName());
}

@Test
public void shouldNotHookIntoDisabledPlugin() {
@ParamTest
void shouldNotHookIntoDisabledPlugin(PermissionsSystemType permissionsSystemType, Class<?> expectedHandlerType) {
// given
given(settings.getProperty(PluginSettings.FORCE_VAULT_HOOK)).willReturn(false);
Plugin plugin = mock(Plugin.class);
@@ -126,8 +121,8 @@ public void shouldNotHookIntoDisabledPlugin() {
assertThat(getHandlerFieldValue(), nullValue());
}

@Test
public void shouldCatchInitializationException() {
@ParamTest
void shouldCatchInitializationException(PermissionsSystemType permissionsSystemType, Class<?> expectedHandlerType) {
// given
given(settings.getProperty(PluginSettings.FORCE_VAULT_HOOK)).willReturn(false);
Plugin plugin = mock(Plugin.class);
@@ -142,8 +137,7 @@ public void shouldCatchInitializationException() {
assertThat(getHandlerFieldValue(), nullValue());
}

@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> createParameters() {
private static Collection<Object[]> createParameters() {
Map<PermissionsSystemType, Class<?>> handlersByPermissionSystemType = ImmutableMap.of(
LUCK_PERMS, LuckPermsHandler.class,
PERMISSIONS_EX, PermissionsExHandler.class,
@@ -163,7 +157,7 @@ public static Collection<Object[]> createParameters() {
.collect(Collectors.toList());
}

private void setUpForPermissionSystemTest() {
private void setUpForPermissionSystemTest(PermissionsSystemType permissionsSystemType) {
if (permissionsSystemType == LUCK_PERMS) {
LuckPermsApi api = mock(LuckPermsApi.class);
ReflectionTestUtils.setField(LuckPerms.class, null, "instance", api);
@@ -190,4 +184,10 @@ private void setUpForVault() {
private PermissionHandler getHandlerFieldValue() {
return ReflectionTestUtils.getFieldValue(PermissionsManager.class, permissionsManager, "handler");
}

@ParameterizedTest(name = "{0}")
@MethodSource("createParameters")
@Retention(RetentionPolicy.RUNTIME)
@interface ParamTest {
}
}