• Home
  • LLMs
  • Python
  • Docker
  • Kubernetes
  • Java
  • Maven
  • All
  • About
Testing | Serenity BDD (JBehave)
  1. References
  2. The POM file (pom.xml)
  3. A very simple story
  4. A very simple Java implementation
  5. Generating the report

  1. References
    See these pages for more details about Serenity and JBehave:
    The Serenity Reference Manual
    JBehave - Core Reference Guide
    JBehave - Eclipse Integration
  2. The POM file (pom.xml)
    <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>mtitek.serenity.samples</groupId>
        <artifactId>mtitek-serenity-samples</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
    
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>net.serenity-bdd</groupId>
                <artifactId>serenity-jbehave</artifactId>
                <version>1.20.0</version>
                <scope>test</scope>
            </dependency>
    
            <dependency>
                <groupId>org.jbehave</groupId>
                <artifactId>jbehave-core</artifactId>
                <version>4.1</version>
                <scope>test</scope>
            </dependency>
    
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>1.1.8</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.6.0</version>
    
                    <configuration>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>net.serenity-bdd.maven.plugins</groupId>
                    <artifactId>serenity-maven-plugin</artifactId>
                    <version>1.2.2</version>
    
                    <executions>
                        <execution>
                            <id>serenity-reports</id>
    
                            <phase>post-integration-test</phase>
    
                            <goals>
                                <goal>aggregate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.19.1</version>
    
                    <configuration>
                        <includes>
                            <include>**/MySampleSerenityStories.java</include>
                        </includes>
                    </configuration>
    
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
  3. A very simple story
    mtitek-serenity-samples/src/test/resources/stories/my-test-1.story

    JBehave Story - A simple test
    
    Narrative:
    
    This is a simple JBehave story test
    
    Scenario: My first JBehave scenario
    
    Given my foo method ...
    Then my bar method ...
  4. A very simple Java implementation
    mtitek-serenity-samples/src/test/java/mtitek/serenity/samples/MySampleSerenityStories.java

    package mtitek.serenity.samples;
    
    import net.serenitybdd.jbehave.SerenityStories;
    
    public class MySampleSerenityStories extends SerenityStories {
    }

    mtitek-serenity-samples/src/test/java/mtitek/serenity/samples/MySampleTest1.java

    package mtitek.serenity.samples;
    
    import org.jbehave.core.annotations.Given;
    import org.jbehave.core.annotations.Then;
    
    public class MySampleTest1 {
        @Given("my foo method ...")
        public void foo() {
            System.out.println("[Given] my foo method ...");
        }
    
        @Then("my bar method ...")
        public void bar() {
            System.out.println("[Then] my bar method ...");
        }
    }
  5. Generating the report
    Run the command "mvn clean verify" to create the report.

    The main HTML page of the report can be found in: target/site/serenity/index.html

    Serenity BDD (JBehave) - Report
© 2025  mtitek