Test Automation Framework. Serenity BDD: Getting Started3 min read
Following its subdued Latin origin, Serenity BDD is a real snatch for Test Automation Framework. Get familiar with this library from A to Z, as well as learn how to create simple projects and run the tests.
Following its subdued Latin origin, Serenity BDD (previously known as Thucydides) is a library for test automation which wraps and extends WebDriver/JUnit functionality. Serenity BDD is well documented and supported, but in references the old name can be used. The reason for changing the name is quite trivial: instead of wondering how Thucydides works, people were puzzled about how on earth to pronounce the word.
In the first part of my Test Automation Framework blog I described most of Serenity’s features. In this article you’ll get familiar with this library from A to Z, as well as learn how to create simple projects and run the tests. Keeping things simple and covering only the necessary steps, let’s get started!
Serenity BDD (from now on let’s only use this name) requires the following tools to be installed:
- Maven 3.0.x or higher
- Java 5 or higher
In this example Eclipse will be used as the Integrated Development Environment (IDE), but you can use any editor you like.
To launch your tests through a command line, edit the Maven settings file:
[MAVEN_INSTALL PATH]\apache-maven-3.x.x\conf\settings.xml. Inside settings block add pluginGroups:
There are two ways to create a simple Maven project for Selenium 2 and JUnit: from command line or through IDE. In this case, a common line is used and then imported as a Maven project.
- Create test folder (e.g.: D:\repo\test) and move to the folder through the command line
- Type the next command and press enter:
mvn archetype:generate -Dfilter=thucydides
In the console window you will be asked to choose the type of the project, select:
- You will be prompted for a version: select the latest version of Serenity BDD and press Enter
- When asked about:
- groupID (value which identifies your project) type some identifier, e.g.: com.thu.tests
- artifcatID (actually this value will be used as the name of your jar file): mytests
When you see the package prompt, press enter to accept the default value
When you see the Y:: prompt, press enter to accept default value
- Having pressed Enter, you should see the message: BUILD SUCCESS.
3: remote -> net.thucydides:thucydides-simple-archetype (Thucydides automated acceptance testing project using Selenium 2 and JUnit)
Generated Sample Overview
So, we have successfully generated a default test project. In case something goes wrong, you can download generated samples from repository. What do these sample tests actually do?
- Open Wiktionary
- Search for apple and verify search results
- Search for pear and verify search results
Importing Project into Eclipse IDE
- Open Eclipse IDE
Click File->Import->Maven-> Existing Maven project
Easy or not, we have managed to set up and launch our test, generate the report and get acquainted with the project structure. It was just an introductory tutorial on how to get Serenity BDD started to implement our tests with JUnit and WebDriver support. The next steps are to implement the same scenarios as BDD acceptance tests. More information and feature descriptions may be found on the home page of the project.