Skip to content

Commit

Permalink
[WIP ] Convert remaining tests to junit 5 (#5394)
Browse files Browse the repository at this point in the history
* [WIP] Convert remaining tests to junit 5

Let's see if that works

* remove junit 4

* temporaily add system.out.prinltn to test if all are run

* fix gradle not executing tests correclty

* fix gradle syntax error

* add more logging

* fix psql driver name and url

* Manually call setup and clear in each test

* fix typo and call clear

* fix unmodifable error

* fix field map error

* fix id

* SetID does not store value as internal id field

* add some comments for further debugging hints

call clear in setup to ensure empty tables and no leftovers from failures

* fix copy paste error

* Cleanup code

* Don't allow codecov to fail

* Temporarily allow failure of database tests

* Readd database test to codecov

* Try to ignore failures the other way

* Or maybe this way?

* Yet another try

* Well...maybe now

Co-Authored-By: Tobias Diez <tobiasdiez@gmx.de>
  • Loading branch information
Siedlerchr and tobiasdiez committed Nov 11, 2019
1 parent df09597 commit 04015b0
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ matrix:
fast_finish: true
allow_failures:
- env: TEST_SUITE=fetcherTest
- env: TEST_SUITE=databaseTest
- env: TEST_SUITE=guiTest
- env: TEST_SUITE=codecov
- env: DEPENDENCY_UPDATES=check

# JavaFX localization tests need a running X environment
Expand Down
54 changes: 43 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ dependencies {


testCompile 'io.github.classgraph:classgraph:4.8.53'
testCompile 'junit:junit:4.12'
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.5.2'
testCompile 'org.junit.platform:junit-platform-launcher:1.5.2'
Expand Down Expand Up @@ -441,31 +440,49 @@ localization.script = 'scripts/syncLang.py'
// Test tasks
test {
useJUnitPlatform {
excludeTags 'DatabaseTest', 'FetcherTest', 'GUITest', 'org.jabref.testutils.category.FetcherTest', 'org.jabref.testutils.category.GUITest'
excludeTags 'DatabaseTest', 'FetcherTest', 'GUITest'
}

testLogging {
// set options for log level LIFECYCLE
events "failed"
events = ["FAILED", "STANDARD_OUT", "STANDARD_ERROR"]
exceptionFormat "full"
}
}

task databaseTest(type: Test) {
useJUnit {
includeCategories 'org.jabref.testutils.category.DatabaseTest'
useJUnitPlatform {
includeTags 'DatabaseTest'
}

testLogging {
// set options for log level LIFECYCLE
events = ["FAILED", "STANDARD_OUT", "STANDARD_ERROR"]
exceptionFormat "full"
}
}

task fetcherTest(type: Test) {
useJUnit {
includeCategories 'org.jabref.testutils.category.FetcherTest'
useJUnitPlatform {
includeTags 'FetcherTest'
}

testLogging {
// set options for log level LIFECYCLE
events = ["FAILED", "STANDARD_OUT", "STANDARD_ERROR"]
exceptionFormat "full"
}
}

task guiTest(type: Test) {
useJUnit {
includeCategories 'org.jabref.testutils.category.GUITest'
useJUnitPlatform {
includeTags 'GUITest'
}

testLogging {
// set options for log level LIFECYCLE
events = ["FAILED", "STANDARD_OUT", "STANDARD_ERROR"]
exceptionFormat "full"
}
}

Expand All @@ -480,9 +497,24 @@ tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}

task jacocoMergePrep() {
doFirst {
// Ignore failures of tests
tasks.withType(Test) {
ignoreFailures = true
}
}
}
test.mustRunAfter jacocoMergePrep
databaseTest.mustRunAfter jacocoMergePrep
fetcherTest.mustRunAfter jacocoMergePrep

task jacocoMerge(type: JacocoMerge) {
executionData file("$buildDir/jacoco/test.exec"), file("$buildDir/jacoco/databaseTest.exec"), file("$buildDir/jacoco/fetcherTest.exec")
dependsOn test, databaseTest, fetcherTest
executionData files(
"$buildDir/jacoco/test.exec",
"$buildDir/jacoco/databaseTest.exec",
"$buildDir/jacoco/fetcherTest.exec").filter { it.exists() }
dependsOn jacocoMergePrep, test, databaseTest, fetcherTest
}

jacocoTestReport {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/jabref/logic/shared/DBMSConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class DBMSConnection implements DatabaseConnection {
private final DBMSConnectionProperties properties;

public DBMSConnection(DBMSConnectionProperties connectionProperties) throws SQLException, InvalidDBMSConnectionPropertiesException {

if (!connectionProperties.isValid()) {
throw new InvalidDBMSConnectionPropertiesException();
}
Expand All @@ -34,7 +33,6 @@ public DBMSConnection(DBMSConnectionProperties connectionProperties) throws SQLE
// we use the side effect of getAvailableDBMSTypes() - it loads all available drivers
DBMSConnection.getAvailableDBMSTypes();
this.connection = DriverManager.getConnection(connectionProperties.getUrl(), connectionProperties.asProperties());

} catch (SQLException e) {
// Some systems like PostgreSQL retrieves 0 to every exception.
// Therefore a stable error determination is not possible.
Expand Down
4 changes: 0 additions & 4 deletions src/test/java/module-info.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
--add-modules
// Make junit4 module visible (only required for last remaining parameterized tests)
junit

--add-modules
// Add junit5 module dependency
org.junit.jupiter.api
Expand Down
Loading

0 comments on commit 04015b0

Please sign in to comment.