Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.zetten:xvfb-maven-plugin:v1.4.0'
}
dependencies {
implementation("com.github.zetten:xvfb-maven-plugin:v1.4.0")
}
<dependency>
<groupId>com.github.zetten</groupId>
<artifactId>xvfb-maven-plugin</artifactId>
<version>v1.4.0</version>
</dependency>
libraryDependencies += "com.github.zetten" % "xvfb-maven-plugin" % "v1.4.0"
:dependencies [[com.github.zetten/xvfb-maven-plugin "v1.4.0"]]
A Maven plugin to manage an Xvfb server. This may be used for headless testing of GUI applications.
Enable the xvfb:run
and xvfb:stop
executions in your module's plugin
configuration.
These goals bind by default to the pre-integration-test
and
post-integration-test
lifecycle phases. When starting up a free X display
port is searched for and Xvfb launched against it, and the process is stopped
after integration tests have run.
The DISPLAY variable corresponding to the temporary Xvfb instance may be passed to integration tests in two ways:
xvfb:run
goal sets a Maven property xvfb.display
which can be used in any other plugin executions (e.g. via the
environmentVariables option of maven-failsafe-plugin
).$DISPLAY
environment
variable directly within the executing JVM is also available, but is not
recommended.For example, to run full-UI tycho-surefire-test executions in their own Xvfb
instances, use configuration like the below in your parent pom.xml. Since the
Tycho test plugin binds to the integration-test
phase, the Xvfb plugin will
wrap their execution and set the xvfb.display
plugin value.
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.zetten</groupId>
<artifactId>xvfb-maven-plugin</artifactId>
<version>${xvfb-maven-plugin.version}</version>
<executions>
<execution>
<id>wrap-tests</id>
<goals>
<goal>run</goal>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<useUIHarness>true</useUIHarness>
<environmentVariables>
<DISPLAY>${xvfb.display}</DISPLAY>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
The approach was inspired by the Jenkins Xvfb plugin, the Selenium Maven Plugin's Xvfb goal and process-exec-maven-plugin.