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

Fix for issue 3959: migrate all tests to JUnit 5 #4260

Merged
merged 76 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5d73b71
Update migrate from JUnit 4 to JUnit 5
1160300305 Aug 6, 2018
cb1b75f
Update migrate from JUnit 4 to JUnit 5
1160300305 Aug 6, 2018
45fa771
Trying to change git accounts on my laptop
1160300305 Aug 6, 2018
ddc898d
Trying to change git accounts on my laptop
1160300305 Aug 6, 2018
553c7b4
Trying to change git accounts on my laptop
Metatronwings Aug 6, 2018
f481f04
Using static assert methods.
Metatronwings Aug 6, 2018
897131d
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 6, 2018
1e0c89e
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 6, 2018
1edf14f
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 6, 2018
5a34921
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 6, 2018
d23dc9c
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 6, 2018
35e7621
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 6, 2018
1c4022e
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 6, 2018
2e63dc1
Trying to change to a new branch.
Metatronwings Aug 7, 2018
959fd13
commit_test
HITTOM Aug 7, 2018
355a71d
delete my meaningless txt
HITTOM Aug 7, 2018
9fc98e7
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
3533b6b
Merge branch 'fix-for-issue-3959' of https://github.com/Metatronwings…
Metatronwings Aug 8, 2018
f74f486
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
a1df42f
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
970502a
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
b18c9ba
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
fb157f4
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
7761b29
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
aeee7ef
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
119f491
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
dbf6341
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
8d3c78e
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
21e539a
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
3b0c544
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
37a0856
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 8, 2018
51ee2aa
Try to trigger the Travis CI build.
Metatronwings Aug 9, 2018
f6690a2
Try to trigger the Travis CI build.
Metatronwings Aug 9, 2018
69a2262
Migrate from JUnit 4 to JUnit 5
HITTOM Aug 9, 2018
fecd37c
Merge branch 'fix-for-issue-3959' of https://github.com/Metatronwings…
HITTOM Aug 9, 2018
c12ccb8
Try to migrate from JUnit 4 to JUnit 5
Metatronwings Aug 10, 2018
ef0a13e
Roll back to earlier version.
Metatronwings Aug 10, 2018
ce4a8d5
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 10, 2018
095822c
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 10, 2018
251a2ed
failed to modify CleanupWorkerTest
HITTOM Aug 10, 2018
08b8d3c
failed to modify cleanupworkTest
HITTOM Aug 10, 2018
47fe3e5
failed to modify cleanupWorkTest
HITTOM Aug 10, 2018
a4826df
change cleanupWorkerTest to initial
HITTOM Aug 10, 2018
ea278c3
***DatabaseTest***
Metatronwings Aug 10, 2018
747d0ae
***DatabaseTest***
Metatronwings Aug 12, 2018
6ca6edb
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 12, 2018
3cf018c
Migrate from JUnit 4 to JUnit 5
Metatronwings Aug 12, 2018
1ee024c
Try to sync.
Metatronwings Aug 12, 2018
82b3083
Migrate JUnit 4 to JUnit 5.
Metatronwings Aug 12, 2018
fd0cc63
Migrate JUnit 4 to JUnit 5.
Metatronwings Aug 12, 2018
622ef47
Migrate JUnit 4 to JUnit 5.
Metatronwings Aug 12, 2018
3efc54b
Fix part of CleanupWorkerTest.
Metatronwings Aug 12, 2018
a4df9c8
Migrate and sync.
Metatronwings Aug 13, 2018
13dcb27
Merge remote-tracking branch 'upstream/master'
Metatronwings Aug 13, 2018
596eabd
Migrate.
Metatronwings Aug 13, 2018
5ad934c
Fix CleanupWorkerTest.java
Metatronwings Aug 13, 2018
a917610
Fix .travis.yml
Metatronwings Aug 13, 2018
b588c53
Remove unnecessary @Rule.
Metatronwings Aug 13, 2018
1c5ab14
AuxParserTest.java
W924 Aug 13, 2018
747fb20
BibtexParserTest.java
W924 Aug 13, 2018
9da75f3
EntryComparatorTest.java
W924 Aug 13, 2018
aad0e4b
Migrate JUnit 4 to JUnit 5 -------by 1160300229
W924 Aug 13, 2018
e55d185
Migrate. Some tasks by my team members.
Metatronwings Aug 13, 2018
6ea8b1c
Fix 1160300302's error.
Metatronwings Aug 13, 2018
6e7c5e6
Remove unnecessary "public".
Metatronwings Aug 13, 2018
ddf52d3
fix architecture test by removing check for public make some classes …
Siedlerchr Aug 13, 2018
faefa6c
Fix "cannot find files" problem in JUnit 4.
Metatronwings Aug 14, 2018
67afcbe
Migrate to JUnit 5.
Metatronwings Aug 14, 2018
4fb0ef0
Change the slash direction.
Metatronwings Aug 14, 2018
fb925e5
fix resolving of paths in msbibexporterpath update junit and correct …
Siedlerchr Aug 14, 2018
f46980d
Fix the path issue in
Metatronwings Aug 14, 2018
5e4324f
Disable the failing exporter tests and change the build.gradle
Metatronwings Aug 15, 2018
3daf305
Merge remote-tracking branch 'upstream/master'
Metatronwings Aug 15, 2018
25030de
Fix the parent folder issue by make every path to their child once.
Metatronwings Aug 15, 2018
a81767a
Fix some minor issues.
Metatronwings Aug 15, 2018
3deb4f8
include main/java in resources as well convert legalcy file methods t…
Siedlerchr Aug 15, 2018
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

24 changes: 16 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ sourceSets {
}

resources {
srcDirs = ["src/main/java", "src/main/resources"]
srcDirs = ["src/main/resources"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"src/main/java" should still be there since otherwise the fxml files in the src folder are not found

}
}
test{
java {
srcDirs = ["src/test/java"]
}
resources {
srcDirs = ["src/test/resources"]
}
}
}
Expand Down Expand Up @@ -152,11 +160,11 @@ dependencies {
compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.1.2'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.1.2'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.2.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.2.0'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.2.0'
testCompile 'org.junit.platform:junit-platform-launcher:1.2.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.0-RC1'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.0-RC1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.0-RC1'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.0-RC1'
testCompile 'org.junit.platform:junit-platform-launcher:1.3.0-RC1'
testCompile 'org.junit-pioneer:junit-pioneer:0.1.2'
testRuntime 'org.apache.logging.log4j:log4j-core:2.11.0'
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.0'
Expand Down Expand Up @@ -197,7 +205,7 @@ dependencyUpdates.resolutionStrategy = {
selection.reject("Cannot be updated to 9.*.* until Jabref works with Java 9")
}
}
rules.withModule("com.github.tomtung:latex2unicode_2.12") { ComponentSelection selection ->
rules.withModule("com.github.tomtung:latex2unicode_2.12") { ComponentSelection selection ->
if (selection.candidate.version ==~ /0.2.2/) { // Reject version higher than 2.0.2
selection.reject("Cannot be updated to 0.2.4 until JabRef is prepared for it")
}
Expand All @@ -212,7 +220,7 @@ dependencyUpdates.resolutionStrategy = {
selection.reject("http://dev.mysql.com/downloads/connector/j/ lists the version 5.* as last stable version.")
}
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/jabref/JabRefPreferencesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class JabRefPreferencesTest {
class JabRefPreferencesTest {

private JabRefPreferences prefs;

@BeforeEach
public void setUp() {
void setUp() {
prefs = mock(JabRefPreferences.class);
when(prefs.getDefaultEncoding()).thenReturn(StandardCharsets.UTF_8);
}

@Test
public void getDefaultEncodingReturnsPreviouslyStoredEncoding() {
void getDefaultEncodingReturnsPreviouslyStoredEncoding() {
prefs.setDefaultEncoding(StandardCharsets.UTF_8);
assertEquals(StandardCharsets.UTF_8, prefs.getDefaultEncoding());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static Stream<String[]> data() {
@MethodSource("data")
public void testsAreIndependent(String forbiddenPackage) throws IOException {
Predicate<String> isForbiddenPackage = (s) -> s.startsWith("import " + forbiddenPackage);
Predicate<String> isExceptionClass = (s) -> exceptions.stream().anyMatch(exception -> s.startsWith("public class " + exception));
Predicate<String> isExceptionClass = (s) -> exceptions.stream().anyMatch(exception -> s.startsWith("class " + exception));

try (Stream<Path> pathStream = Files.walk(Paths.get("src/test/"))) {
List<Path> files = pathStream
Expand Down
9 changes: 4 additions & 5 deletions src/test/java/org/jabref/gui/AbstractUITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.nio.file.Paths;

import org.jabref.JabRefMain;
import org.jabref.testutils.category.GUITest;

import org.assertj.swing.fixture.AbstractWindowFixture;
import org.assertj.swing.fixture.FrameFixture;
Expand All @@ -17,12 +16,12 @@
import org.assertj.swing.image.ScreenshotTaker;
import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase;
import org.assertj.swing.timing.Pause;
import org.junit.Assert;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;

import static org.assertj.swing.launcher.ApplicationLauncher.application;
import static org.junit.jupiter.api.Assertions.assertEquals;

@Category(GUITest.class)
@Tag("GUITest")
public abstract class AbstractUITest extends AssertJSwingJUnitTestCase {

protected final static int SPEED_NORMAL = 50;
Expand Down Expand Up @@ -105,6 +104,6 @@ protected void assertColumnValue(JTableFixture table, int rowIndex, int columnIn
tableContent = table.contents();

String value = tableContent[rowIndex][columnIndex];
Assert.assertEquals(value, selectionValue);
assertEquals(value, selectionValue);
}
}
7 changes: 3 additions & 4 deletions src/test/java/org/jabref/gui/DialogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
import javax.swing.JButton;
import javax.swing.JDialog;

import org.jabref.testutils.category.GUITest;

import org.assertj.swing.core.GenericTypeMatcher;
import org.assertj.swing.dependency.jsr305.Nonnull;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import static org.assertj.swing.finder.WindowFinder.findDialog;
/**
* This test has been split to work, the other part can be found at DialogTest2
*/
@Category(GUITest.class)
@Tag("GUITest")
public class DialogTest extends AbstractUITest {

@Test
Expand Down
9 changes: 3 additions & 6 deletions src/test/java/org/jabref/gui/DialogTest2.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package org.jabref.gui;


import javax.swing.JButton;
import javax.swing.JDialog;

import org.jabref.testutils.category.GUITest;

import org.assertj.swing.core.GenericTypeMatcher;
import org.assertj.swing.dependency.jsr305.Nonnull;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import static org.assertj.swing.finder.WindowFinder.findDialog;

/**
* Split of DialogTest, since the test cases were only running separately
*/
@Category(GUITest.class)
@Tag("GUITest")
public class DialogTest2 extends AbstractUITest {
@Test
public void testCloseStyleSelectDialog() {
Expand Down
15 changes: 7 additions & 8 deletions src/test/java/org/jabref/gui/EntryTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
import java.awt.event.KeyEvent;
import java.util.regex.Pattern;

import org.jabref.testutils.category.GUITest;

import org.assertj.swing.fixture.JTableCellFixture;
import org.assertj.swing.fixture.JTableFixture;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
* Specific Use-Case:
* I import a database. Then I doubleclick on the first entry in the table to open the entry editor.
* Then I click on the first entry again, and scroll through all of the lists entries, without having to click
* on the table again.
*/
@Category(GUITest.class)
@Tag("GUITest")
public class EntryTableTest extends AbstractUITest{

private final static int SCROLL_ACTION_EXECUTION = 5;
Expand Down Expand Up @@ -51,13 +50,13 @@ public void scrollThroughEntryList() {
//go throught the table and check if the entry with the correct index is selected
for (int i=0; i < SCROLL_ACTION_EXECUTION; i++) {
robot().pressAndReleaseKey(DOWN);
Assert.assertTrue(entryTable.selectionValue() != null);
assertNotNull(entryTable.selectionValue());
assertColumnValue(entryTable, i+1, TITLE_COLUMN_INDEX, entryTable.selectionValue());
}
//do the same going up again
for (int i = SCROLL_ACTION_EXECUTION; i > 0; i--) {
robot().pressAndReleaseKey(UP);
Assert.assertTrue(entryTable.selectionValue() != null);
assertNotNull(entryTable.selectionValue());
assertColumnValue(entryTable, i-1, TITLE_COLUMN_INDEX, entryTable.selectionValue());
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/jabref/gui/GUITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import org.assertj.swing.core.GenericTypeMatcher;
import org.assertj.swing.dependency.jsr305.Nonnull;
import org.assertj.swing.fixture.DialogFixture;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import static org.assertj.swing.finder.WindowFinder.findDialog;

@Category(org.jabref.testutils.category.GUITest.class)
@Tag("GUITest")
public class GUITest extends AbstractUITest {

@Test
Expand Down
39 changes: 13 additions & 26 deletions src/test/java/org/jabref/gui/IdFetcherDialogTest.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,29 @@
package org.jabref.gui;


import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Stream;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.text.JTextComponent;

import org.jabref.testutils.category.GUITest;

import org.assertj.swing.core.GenericTypeMatcher;
import org.assertj.swing.dependency.jsr305.Nonnull;
import org.assertj.swing.fixture.JTableFixture;
import org.assertj.swing.timing.Condition;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import static org.assertj.swing.finder.WindowFinder.findDialog;
import static org.assertj.swing.timing.Pause.pause;

@RunWith(Parameterized.class)
@Category(GUITest.class)
@Tag("GUITest")
public class IdFetcherDialogTest extends AbstractUITest {

private final String databaseMode, fetcherType, fetchID;

public IdFetcherDialogTest(String databaseMode, String fetcherType, String fetchID) {
this.databaseMode = databaseMode;
this.fetcherType = fetcherType;
this.fetchID = fetchID;
}

@Test
public void insertEmptySearchID() {
@ParameterizedTest
@MethodSource("instancesToTest")
public void insertEmptySearchID(String databaseMode, String fetcherType, String fetchID) {
mainFrame.menuItemWithPath("File", "New " + databaseMode + " database").click();
JTableFixture entryTable = mainFrame.table();

Expand Down Expand Up @@ -76,8 +63,9 @@ protected boolean isMatching(@Nonnull JButton jButton) {
entryTable.requireRowCount(0);
}

@Test
public void testFetcherDialog() {
@ParameterizedTest
@MethodSource("instancesToTest")
public void testFetcherDialog(String databaseMode, String fetcherType, String fetchID) {
mainFrame.menuItemWithPath("File", "New " + databaseMode + " database").click();
JTableFixture entryTable = mainFrame.table();

Expand Down Expand Up @@ -123,9 +111,8 @@ public boolean test() {
}


@Parameterized.Parameters(name = "{index}: {0} : {1} : {2}")
public static Collection<Object[]> instancesToTest() {
return Arrays.asList(
public static Stream<Object[]> instancesToTest() {
return Stream.of(
new Object[]{"BibTeX", "DOI", "10.1002/9781118257517"},
new Object[]{"biblatex", "DOI", "10.1002/9781118257517"},
new Object[]{"BibTeX", "ISBN", "9780321356680"},
Expand Down
Loading