Serenity BDD Overview

Introduction

Use your Serenity acceptance test to monitor, performance, and load test your websites and APIs.

Check out the Getting Started with Serenity BDD guide for a quick introduction on how to run your test cases. Also check out our Selenium overview guide to better understand how Selenium tests run on Testable in general.

This document goes into further detail on the various options provided for running Serenity BDD scenarios on Testable.

Creating a Scenario

There are two ways to create a scenario:

  1. Create a new Test Case (Create Test button on the dashboard or Test Cases -> New… on the left nav), select Selenium during step 2.
  2. Go to an existing test case and click on the Scenario tab. Click the New Scenario button and select Selenium as the scenario type.

Source

There are several ways to load your Selenium Java scenario into the Testable platform.

  1. Upload Project Source as Zip File: Upload a zip file with all source code and configuration. Code is unzipped then built and run using Maven or Gradle. See below for more details.
  2. Build Project from Version Control: Project is cloned from version control onto the test runner. Code is built and run using Maven or Gradle. See below for more details.

Integration with Testable

Serenity injects a managed WebDriver instance into your tests. When running on Testable we ensure that Serenity is configured such that the webdriver.remote.url points to the locally running Selenium server.

Your project can configure any Serenity property as either a scenario parameter (passed as a System property to your tests) or in a serenity.properties file. Certain properties will be overridden by Testable when run on one of our test runners.

See our serenity-example project for more details and several example tests.

Build Step

If you choose to link your Git repository or upload a source zip your code needs to be compiled and built on the test runner. We support both Gradle and Maven to do this.

Gradle Build

Testable will use Gradle to build and run the tests in your project if it detects a build.gradle file in the project root. To simulate this locally simply run gradle clean test. All scenario parameters will be available as system properties and environment variables at runtime.

Our example project is a good place to start.

build.gradle

group 'io.testable'
version '1.0-SNAPSHOT'

repositories {
    mavenLocal()
    jcenter()
}

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath("net.serenity-bdd:serenity-gradle-plugin:1.1.1")
    }
}

apply plugin: 'java'
apply plugin: 'net.serenity-bdd.aggregator'

dependencies {
    testCompile 'net.serenity-bdd:serenity-core:1.1.1'
    testCompile 'net.serenity-bdd:serenity-junit:1.1.1'
    testCompile('junit:junit:4.12')
    testCompile('org.assertj:assertj-core:1.7.0')
    testCompile('org.slf4j:slf4j-simple:1.7.7')
}
gradle.startParameter.continueOnFailure = true

Maven Build

Testable will use Maven to build and run your project if it detects a pom.xml file in the project root. To simulate this locally simply run mvn clean verify -Dexec.cleanupDaemonThreads=false -Dmaven.test.failure.ignore=true. All scenario parameters will be available as system properties and environment variables at runtime.

Our example project is a good place to start.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>io.testable</groupId>
    <artifactId>testable-serenity-example</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Example Serenity Project for Testable</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <serenity.version>1.1.1</serenity.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenity.version}</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-junit</artifactId>
            <version>${serenity.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>1.7.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

If both a build.gradle and pom.xml file are detected in your project root folder, Gradle takes precedence.

Results and Screenshots

All test results are captured and reported back to Testable including any screenshots captured during testing.

These test results will be visible in several places.

Assertions Widget: Aggregated results are visible in the Assertions widget.

Image Details: Click the name of any image in the Images widget to see the related test result including any error traces.

Test Results: Within the Results widget (Slowest Iterations => [select an iteration]) you can see all test results that were captured as part of that iteration.