diff --git a/.sdkmanrc b/.sdkmanrc new file mode 100644 index 0000000..cb8d5cb --- /dev/null +++ b/.sdkmanrc @@ -0,0 +1 @@ +java=17.0.12-librca \ No newline at end of file diff --git a/README.md b/README.md index 5c3a0e6..897c0b6 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,13 @@ Just run `./gradlew integrationTest` and a container will be started and configu The annotation `ContainerGebConfiguration` exists to customize the connection the container will use to access the application under test. The annotation is not required and `ContainerGebSpec` will use the default values in this annotation if it's not present. #### Recording -By default, no test recording will be performed. Here are the system properties available to change the recording behavior: + +By default, no test recording will be performed. Various system properties exist to change the recording behavior. To set them, you can set them in your `build.gradle` file like so: + + tasks.withType(Test) { + useJUnitPlatform() + systemProperty 'grails.geb.recording.mode', 'RECORD_ALL' + } * `grails.geb.recording.mode` * purpose: which tests to record diff --git a/src/testFixtures/groovy/grails/plugin/geb/ContainerGebRecordingExtension.groovy b/src/testFixtures/groovy/grails/plugin/geb/ContainerGebRecordingExtension.groovy index 80dfde2..931c694 100644 --- a/src/testFixtures/groovy/grails/plugin/geb/ContainerGebRecordingExtension.groovy +++ b/src/testFixtures/groovy/grails/plugin/geb/ContainerGebRecordingExtension.groovy @@ -44,6 +44,11 @@ class ContainerGebRecordingExtension implements IGlobalExtension { } } + @Override + void stop() { + holder.stop() + } + @Override void visitSpec(SpecInfo spec) { if (isContainerGebSpec(spec) && validateContainerGebSpec(spec)) { diff --git a/src/testFixtures/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy b/src/testFixtures/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy index aaf9be0..60a8f67 100644 --- a/src/testFixtures/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy +++ b/src/testFixtures/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy @@ -86,6 +86,13 @@ class WebDriverContainerHolder { configuration = specConfiguration currentContainer = new BrowserWebDriverContainer() + if (recordingSettings.recordingEnabled) { + currentContainer = currentContainer.withRecordingMode( + recordingSettings.recordingMode, + recordingSettings.recordingDirectory, + recordingSettings.recordingFormat + ) + } Testcontainers.exposeHostPorts(configuration.port) currentContainer.tap { addExposedPort(configuration.port) @@ -96,14 +103,6 @@ class WebDriverContainerHolder { currentContainer.execInContainer('/bin/sh', '-c', "echo '$hostIp\t${configuration.hostName}' | sudo tee -a /etc/hosts") } - if (recordingSettings.recordingEnabled) { - currentContainer = currentContainer.withRecordingMode( - recordingSettings.recordingMode, - recordingSettings.recordingDirectory, - recordingSettings.recordingFormat - ) - } - WebDriver driver = new RemoteWebDriver(currentContainer.seleniumAddress, new ChromeOptions()) driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30))