Skip to content

Commit

Permalink
Add documentation & ensure recording is configured before the contain…
Browse files Browse the repository at this point in the history
…er start
  • Loading branch information
jdaugherty committed Nov 25, 2024
1 parent 4c5512e commit a2eff1b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java=17.0.12-librca
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class ContainerGebRecordingExtension implements IGlobalExtension {
}
}

@Override
void stop() {
holder.stop()
}

@Override
void visitSpec(SpecInfo spec) {
if (isContainerGebSpec(spec) && validateContainerGebSpec(spec)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))

Expand Down

0 comments on commit a2eff1b

Please sign in to comment.