-
Notifications
You must be signed in to change notification settings - Fork 1
Getting started
The set up step to use Sahagin-Groovy with Geb.
Unlike Sahagin-Java, Sahagin-Groovy does not require any additional JVM argument.
Add dependency to your build.gradle file.
dependencies {
// use the current latest version
compile 'org.sahagin:sahagin-groovy:0.10.1'
}
Add dependency to your pom.xml file.
<dependencies>
<dependency>
<groupId>org.sahagin</groupId>
<artifactId>sahagin-groovy</artifactId>
<!-- use the current latest version -->
<version>0.10.1</version>
</dependency>
</dependencies>
Add @PageDoc annotations to your Geb page object class declarations, and define testDoc for each page object content in "contentTestDoc" field.
import geb.Page
import org.sahagin.runlib.external.PageDoc
import org.sahagin.runlib.external.TestDoc
@PageDoc("Contact page")
class ContactPage extends Page {
static url = "...."
static content = {
name { $(name: "your-name") }
mail { $(name: "your-mail") }
....
}
static contentTestDoc = {
name { "name" }
mail { "mail address" }
....
}
....
}
You can also add @TestDoc annotations to test methods just like Sahagin-Java, see 2. Add annotations of Sahagin-Java.
Content DSLs without contentTestDoc, or classes or methods without the annotations, are also displayed on the Sahagin report, so you don't need to add them to all your content DSLs, classes and methods.
To take screen captures, call GebAdapter.setAdapter method with Geb Browser instance used in each test at Spock setup method or JUnit4 @Before method or other test set up method.
The following code is Geb and Spock example:
import geb.spock.GebSpec
import org.sahagin.groovy.runlib.external.adapter.geb.GebAdapter
class SampleSpec extends GebSpec {
def setup() {
GebAdapter.setAdapter(getBrowser())
}
....
}
and the following code is Geb and JUnit4 example:
import geb.junit4.GebTest
import org.sahagin.groovy.runlib.external.adapter.geb.GebAdapter
class SampleSpec extends GebTest {
@Before
void setUp() {
GebAdapter.setAdapter(getBrowser())
}
....
}
Create a file "sahagin.yml" on the Groovy project root directory.
Then change the "testDir" value to the directory your test files are located.
# Sahagin configuration file written by YAML style.
groovy:
# Root directory of test Groovy files
# (absolute path or relative path from this YAML file).
# All test methods and methods or content DSLs with TestDoc
# must be located under this directory.
testDir: src/test/groovy
If you use not Spock but JUnit4, you must add the following additional entry:
groovy:
testFramework: jUnit4
Run your Spock or JUnit4 tests.
After the tests run, the HTML report sahagin-rerpot/index.html is generated on the sahagin.yml directory.

Jenkins Sahagin plug-in displays HTML report generated by Sahagin Groovy on Jenkins.
Set up the plug-in according to 6. Set up Jenkins plug-in of Sahagin-Java.
If you want to know more about Sahagin-Groovy features, go to Various features.