ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Solution for automated testing web apps
Vadym Goncharenko, December 2013
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 ?
Behavior driven development
Behavior-driven development is a software development process
based on test-driven development (TDD)
Introduction to JBehave
JBehave is a framework for Behaviour-Driven Development
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.
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
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() {
}
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
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.
Reporting Jbehave results
Questions ?

More Related Content

Jbehave selenium

  • 1. Solution for automated testing web apps Vadym Goncharenko, December 2013
  • 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 ?
  • 3. Behavior driven development Behavior-driven development is a software development process based on test-driven development (TDD)
  • 4. Introduction to JBehave JBehave is a framework for Behaviour-Driven Development
  • 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.