Keep Mockito versions in sync; small fixes after JUnit 5 migration

This commit is contained in:
ljacqu 2023-12-21 17:27:19 +01:00
parent 13087f7322
commit 6161d95f56
4 changed files with 17 additions and 6 deletions

View File

@ -212,7 +212,7 @@
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version> <version>0.8.11</version>
<executions> <executions>
<execution> <execution>
<id>pre-unit-test</id> <id>pre-unit-test</id>
@ -1039,7 +1039,7 @@
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId> <artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope> <scope>test</scope>
<version>2.27.0</version> <version>4.11.0</version>
</dependency> </dependency>
<!-- Required to mock the LuckPerms API--> <!-- Required to mock the LuckPerms API-->

View File

@ -120,8 +120,8 @@ class ConsoleLoggerTest {
@Test @Test
void shouldLogStackTraceToFile() throws IOException { void shouldLogStackTraceToFile() throws IOException {
// given // given
Settings settings = newSettings(true, LogLevel.INFO); Settings settings = mock(Settings.class);
settings.getProperty(PluginSettings.LOG_LEVEL); // dummy code to avoid Mockito from complaining about the log level being stubbed given(settings.getProperty(SecuritySettings.USE_LOGGING)).willReturn(true);
ConsoleLogger.initializeSharedSettings(settings); ConsoleLogger.initializeSharedSettings(settings);
Exception e = new IllegalStateException("Test exception message"); Exception e = new IllegalStateException("Test exception message");

View File

@ -120,9 +120,20 @@ public final class TestHelper {
.willAnswer(invocation -> ((Property<?>) invocation.getArgument(0)).getDefaultValue()); .willAnswer(invocation -> ((Property<?>) invocation.getArgument(0)).getDefaultValue());
} }
/**
* Creates a file with the given name in the provided folder. Throws an exception if the file
* could not be created.
*
* @param folder the folder to create the file in
* @param filename the name of the file to create
* @return the created file
*/
public static File createFile(File folder, String filename) throws IOException { public static File createFile(File folder, String filename) throws IOException {
File file = new File(folder, filename); File file = new File(folder, filename);
file.createNewFile(); boolean created = file.createNewFile();
if (!created) {
throw new IllegalStateException("Could not create file '" + filename + "' in " + folder);
}
return file; return file;
} }
} }

View File

@ -16,7 +16,7 @@ import static org.mockito.Mockito.mock;
class PlayerUtilsTest { class PlayerUtilsTest {
@BeforeAll @BeforeAll
static void setAuthmeInstance() { static void setUpLogger() {
TestHelper.setupLogger(); TestHelper.setupLogger();
} }