@@ -49,10 +49,10 @@ dependencies {
49
49
testRuntimeOnly " com.microsoft.sqlserver:mssql-jdbc:12.2.0.jre11"
50
50
51
51
// JDBC driver for Testcontainers with MariaDB Server
52
- testRuntimeOnly " org.mariadb.jdbc:mariadb-java-client:3.1.4" ;
52
+ testRuntimeOnly " org.mariadb.jdbc:mariadb-java-client:3.1.4"
53
53
54
54
// JDBC driver for Testcontainers with MYSQL Server
55
- testRuntimeOnly " com.mysql:mysql-connector-j:8.0.33" ;
55
+ testRuntimeOnly " com.mysql:mysql-connector-j:8.0.33"
56
56
57
57
// JDBC driver for Db2 server, for testing
58
58
testRuntimeOnly " com.ibm.db2:jcc:11.5.8.0"
@@ -78,10 +78,6 @@ dependencies {
78
78
testImplementation " org.testcontainers:oracle-xe:${ testcontainersVersion} "
79
79
}
80
80
81
- test {
82
- useJUnitPlatform()
83
- }
84
-
85
81
// Print a summary of the results of the tests (number of failures, successes and skipped)
86
82
def loggingSummary (db , result , desc ) {
87
83
if ( ! desc. parent ) { // will match the outermost suite
@@ -91,38 +87,52 @@ def loggingSummary(db, result, desc) {
91
87
}
92
88
}
93
89
90
+ // Example:
91
+ // gradle test -Pdb=MySQL
92
+ test {
93
+ def selectedDb = project. hasProperty( ' db' )
94
+ ? project. properties[' db' ]
95
+ : ' PostgreSQL'
96
+ doFirst {
97
+ systemProperty ' db' , selectedDb
98
+ }
99
+ afterSuite { desc , result ->
100
+ loggingSummary( selectedDb, result, desc )
101
+ }
102
+ }
103
+
94
104
// Configuration for the tests
95
- tasks. withType(Test ) {
105
+ tasks. withType( Test ) . configureEach {
96
106
defaultCharacterEncoding = " UTF-8"
107
+ useJUnitPlatform()
97
108
testLogging {
98
- displayGranularity 1
99
109
showStandardStreams = project. hasProperty(' showStandardOutput' )
100
110
showStackTraces = true
101
111
exceptionFormat = ' full'
102
- events ' PASSED' , ' FAILED' , ' SKIPPED'
112
+ displayGranularity = 1
113
+ events = [' PASSED' , ' FAILED' , ' SKIPPED' ]
103
114
}
104
115
systemProperty ' docker' , project. hasProperty( ' docker' ) ? ' true' : ' false'
105
116
systemProperty ' org.hibernate.reactive.common.InternalStateAssertions.ENFORCE' , ' true'
106
117
107
118
if ( project. hasProperty( ' includeTests' ) ) {
108
119
// Example: ./gradlew testAll -PincludeTests=DefaultPortTest
109
120
filter {
110
- includeTestsMatching project. getProperty( ' includeTests' ) ?: ' *'
121
+ includeTestsMatching project. properties[ ' includeTests' ] ?: ' *' as String
111
122
}
112
123
}
113
124
}
114
125
115
- // Example:
116
- // gradle test -Pdb=MySQL
117
- test {
118
- def selectedDb = project. hasProperty( ' db' )
119
- ? project. getProperty( ' db' )
120
- : ' PostgreSQL'
121
- afterSuite { desc , result ->
122
- loggingSummary( selectedDb, result, desc )
123
- }
124
- doFirst {
125
- systemProperty ' db' , selectedDb
126
+ def createTestDbTask (dbName ) {
127
+ tasks. register( " testDb${ dbName} " , Test ) {
128
+ description = " Run tests for ${ dbName} "
129
+
130
+ doFirst() {
131
+ systemProperty ' db' , dbName
132
+ }
133
+ afterSuite { desc , result ->
134
+ loggingSummary( dbName, result, desc )
135
+ }
126
136
}
127
137
}
128
138
@@ -132,22 +142,16 @@ test {
132
142
// gradle testDbMySQL testDbDB2
133
143
tasks. addRule( " Pattern testDb<id>" ) { String taskName ->
134
144
if ( taskName. startsWith( " testDb" ) ) {
135
- task( type : Test , taskName ) {
136
- def dbName = taskName. substring( " testDb" . length() )
137
- description = " Run tests for ${ dbName} "
138
-
139
- afterSuite { desc , result ->
140
- loggingSummary( dbName, result, desc )
141
- }
142
- doFirst() {
143
- systemProperty ' db' , dbName
144
- }
145
- }
145
+ def dbName = taskName. substring( " testDb" . length() )
146
+ createTestDbTask( dbName )
146
147
}
147
148
}
148
149
149
150
// The dbs we want to test when running testAll
150
151
def dbs = [' MariaDB' , ' MySQL' , ' PostgreSQL' , ' DB2' , ' CockroachDB' , ' MSSQLServer' , ' Oracle' ]
151
- task testAll ( dependsOn : dbs. collect( [] as HashSet ) { db -> " testDb${ db} " } ) {
152
+ dbs. forEach { createTestDbTask it }
153
+
154
+ tasks. register( " testAll" , Test ) {
152
155
description = " Run tests for ${ dbs} "
156
+ dependsOn = dbs. collect( [] as HashSet ) { db -> " testDb${ db} " }
153
157
}
0 commit comments