This document outlines an agenda for a presentation on automated testing of web applications using behavior driven development, JBehave, and Selenium. It discusses behavior driven development, an introduction to the JBehave framework, automated testing with Selenium, the page object pattern, adding new test scenarios, running tests through Maven, best practices, and reporting test results. The document provides examples of how to implement various aspects like page objects, test scenarios, and using Maven for building and running tests.
2. Agenda:
1. Behavior driven development
2. Introduction to JBehave
3. Automated testing with Selenium
4. The page objects pattern
5. How to add new test scenario
6. Running test scenarios through maven
7. An example of best practice
8. Reporting JBehave results
9. Questions ?
5. Automated testing with selenium
? Selenium is a suite of tools to automate web browsers across
many platforms.
? Selenium IDE is a complete integrated development
environment (IDE) for Selenium tests.
? Selenium Remote Control (RC) is a server, written in Java, that
accepts commands for the browser via HTTP.
? Selenium WebDriver is the successor to Selenium RC.
6. The page objects pattern
? More popular in test automation;
? Page object is an object-oriented;
? Serves as an interface to a page;
Enhancing test maintenance;
Reducing code duplication;
Web page Java class Test cases
7. How to add new test scenario
? Write new test scenario on the Gherkin like:
Scenario: ¡°describes what should be passed¡±
Given: ¡°given something¡±
When: ¡°something happened¡±
Then: ¡°should be something¡±
? Implementation for this scenario
@Given ("given something")
public void givenSomething() {
}
@When ("something happened")
public void whenSomethingHappened() {
}
@Then ("should be something")
public void thenShouldBeSomething() {
}
8. Running test scenarios through maven
Maven is a build automation tool used primarily for Java projects
Basic concepts, examples:
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>3.4</version>
</dependency>
<execution>
<id>unpack-view-resources</id>
<phase>process-resources</phase>
<goals>
<goal>unpack-view-resources</goal>
</goals>
</execution>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerVersion>1.5</compilerVersion>
</configuration>
</plugin>
mvn clean install
mvn install ¨CDtest=testname
mvn install -DskipTests
9. An example of best practices
? Each scenario must make sense and be able to be executed
independently;
? Stories may be dependent of each other. If so, they must
declare their dependencies;
? A scenario should consist of steps: "Given¡°, "When¡°, "Then";
? Steps of type "Given" and "When" should not perform a
verification;
? Steps of type "Then" should not perform actions;
? Each scenario should not run longer than 3 minutes.
? Step names should be written in business language terms.