Basic Maven Example
Below is a simple workflow for executing tests in a Maven project stored on GitHub. You can paste this directly into the
YAML of an existing or new test, just make sure to update the name
and namespace
for your environment as needed.
- The
spec.content
property defines the path to the Maven project on GitHub - the
spec.container
property defines default constraints for any container created in this workflow - the
spec.steps
property defines a single step that runs themvn:test
Basic Maven Workflow
kind: TestWorkflow
apiVersion: testworkflows.testkube.io/v1
metadata:
name: maven-sample
namespace: testkube
labels:
docs: example
spec:
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- contrib/executor/maven/examples/hello-maven
container:
workingDir: /data/repo/contrib/executor/maven/examples/hello-maven
resources:
requests:
cpu: 256m
memory: 256Mi
steps:
- name: Run tests
run:
image: maven:3.9.6-eclipse-temurin-11-focal
env:
- name: TESTKUBE_MAVEN
value: "true"
shell: |
mvn test
After execution, you can see the log output from the test executions under the executions panel tabs:
tip
The Selenium Example also uses Maven for running tests and shows how to collect artifacts created by the Maven Surefire plugin.
Basic Maven from Template
Below is an example workflow for executing a Maven project using an official Testkube Template.
Basic Maven Workflow from Template
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: maven-sample-from-template
namespace: testkube
labels:
docs: example
spec:
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- contrib/executor/maven/examples/hello-maven
container:
workingDir: /data/repo/contrib/executor/maven/examples/hello-maven
env:
- name: TESTKUBE_MAVEN
value: "true"
steps:
- name: Run from template
template:
name: official/maven/v1
config:
version: 3.9.6-eclipse-temurin-11-focal