-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add reporting support to ContainerGebSpec (#78)
Introduces a `boolean reportingEnabled = false` property in `ContainerGebSpec` that subclasses can override to enable reporting functionality. To enable reporting, you must also specify the `reportsDir` property. This can typically be configured in `resources/GebConfig.groovy` or via the `geb.reportsDir` system property.
- Loading branch information
Showing
2 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/testFixtures/groovy/grails/plugin/geb/GebTestManagerProvider.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2024 original author or authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package grails.plugin.geb | ||
|
||
import geb.spock.SpockGebTestManagerBuilder | ||
import geb.test.GebTestManager | ||
import groovy.transform.CompileStatic | ||
|
||
/** | ||
* A provider class for managing instances of {@link GebTestManager}. | ||
* This class uses the Initialization-on-Demand Holder Idiom to ensure thread-safe, | ||
* lazy initialization of {@link GebTestManager} instances for use in Geb tests. | ||
* | ||
* <p>The class provides two static instances:</p> | ||
* <ul> | ||
* <li>{@code instance}: A standard {@link GebTestManager} instance.</li> | ||
* <li>{@code reportingInstance}: A {@link GebTestManager} instance with reporting enabled.</li> | ||
* </ul> | ||
* | ||
* <p>This class cannot be instantiated, as it is designed to be used as a | ||
* utility provider.</p> | ||
* | ||
* @see GebTestManager | ||
* @see SpockGebTestManagerBuilder | ||
* | ||
* @author Mattias Reichel | ||
* @author Søren Berg Glasius | ||
* @since 5.0 | ||
*/ | ||
@CompileStatic | ||
class GebTestManagerProvider { | ||
|
||
/** | ||
* A lazily and thread-safe-initialized instance of {@link GebTestManager}. | ||
* Built using {@link SpockGebTestManagerBuilder}. | ||
*/ | ||
@Lazy | ||
static volatile GebTestManager instance = { | ||
new SpockGebTestManagerBuilder().build() | ||
}() | ||
|
||
/** | ||
* A lazily and thread-safe-initialized instance of {@link GebTestManager} | ||
* with reporting enabled. Built using {@link SpockGebTestManagerBuilder}. | ||
*/ | ||
@Lazy | ||
static volatile GebTestManager reportingInstance = { | ||
new SpockGebTestManagerBuilder() | ||
.withReportingEnabled(true) | ||
.build() | ||
}() | ||
|
||
/** | ||
* Private constructor to prevent instantiation of this utility class. | ||
*/ | ||
private GebTestManagerProvider() {} | ||
|
||
} |