@@ -26,12 +26,10 @@ import grails.util.Holders
2626import groovy.json.JsonOutput
2727import groovy.sql.Sql
2828import groovy.transform.TupleConstructor
29- import org.junit.Rule
30- import org.junit.rules.TemporaryFolder
31- import org.junit.rules.TestName
3229import org.slf4j.Logger
3330import org.slf4j.LoggerFactory
3431import spock.lang.Specification
32+ import spock.lang.TempDir
3533
3634import de.dkfz.roddy.BEException
3735import de.dkfz.roddy.execution.jobs.*
@@ -55,7 +53,9 @@ import de.dkfz.tbi.otp.workflowExecution.log.WorkflowError
5553import de.dkfz.tbi.otp.workflowExecution.log.WorkflowLog
5654import de.dkfz.tbi.util.TimeFormats
5755
56+ import javax.inject.Inject
5857import javax.sql.DataSource
58+ import java.lang.reflect.Method
5959import java.nio.file.*
6060import java.nio.file.attribute.PosixFilePermission
6161import java.time.Duration
@@ -108,14 +108,8 @@ abstract class AbstractWorkflowSpec extends Specification implements UserAndRole
108108 /**
109109 * Needed to save the place of the database dump afterwards.
110110 */
111- @Rule
112- TemporaryFolder temporaryFolder
113-
114- /**
115- * Allow the access of the current test method name
116- */
117- @Rule
118- TestName methodName
111+ @TempDir
112+ Path tempDir
119113
120114 /**
121115 * holds the remote file system
@@ -221,10 +215,10 @@ abstract class AbstractWorkflowSpec extends Specification implements UserAndRole
221215
222216 @SuppressWarnings (" CatchThrowable" )
223217 void setup () {
224- log. debug(" Start to setup ${ getClass().simpleName} .${ methodName.methodName } " )
218+ log. debug(" Start to setup ${ getClass().simpleName} .${ specificationContext.currentIteration.name } " )
225219 SessionUtils . withTransaction {
226220 sql = new Sql (dataSource)
227- schemaDump = new File (temporaryFolder . newFolder(), " test-database-dump.sql" )
221+ schemaDump = tempDir . resolve( " test-database-dump.sql" ) . toFile( )
228222 sql. execute(" SCRIPT NODATA DROP TO ?" , [schemaDump. absolutePath])
229223 log. debug(" database dump written to ${ schemaDump} " )
230224
@@ -247,9 +241,10 @@ abstract class AbstractWorkflowSpec extends Specification implements UserAndRole
247241
248242 @SuppressWarnings (" CatchThrowable" )
249243 void cleanup () {
244+ String methodName = specificationContext. currentIteration. name
250245 try {
251246 log. info(" --------------------------------------------------" )
252- log. info(" Starting cleanup after test '${ getClass().simpleName} .${ methodName.methodName } ' for base directory: ${ workingDirectory} " )
247+ log. info(" Starting cleanup after test '${ getClass().simpleName} .${ methodName} ' for base directory: ${ workingDirectory} " )
253248
254249 workflowSystemService. stopWorkflowSystem()
255250
@@ -272,7 +267,7 @@ abstract class AbstractWorkflowSpec extends Specification implements UserAndRole
272267 sql. execute(" DROP ALL OBJECTS" )
273268 sql. execute(" RUNSCRIPT FROM ?" , [schemaDump. absolutePath])
274269
275- log. info " Finish test '${ getClass().simpleName} .${ methodName.methodName } ' using base directory: ${ workingDirectory} "
270+ log. info " Finish test '${ getClass().simpleName} .${ methodName} ' using base directory: ${ workingDirectory} "
276271 } catch (Throwable t) {
277272 // exception in cleanup was not reported with stacktrace, therefore add own logging
278273 log. error(" cleanup error" , t)
0 commit comments