Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First commit

  • Loading branch information...
commit 9b8b6c129fa7cef58b759a4ba06f4eced769d786 0 parents
@wakaleo wakaleo authored
Showing with 589 additions and 0 deletions.
  1. +16 −0 .gitignore
  2. +15 −0 thucydides-showcase-simple-webtests/.gitignore
  3. +189 −0 thucydides-showcase-simple-webtests/pom.xml
  4. +39 −0 ...ydides-showcase-simple-webtests/src/main/java/net/thucydides/showcase/simple/pages/ArtifactDetailsPage.java
  5. +25 −0 thucydides-showcase-simple-webtests/src/main/java/net/thucydides/showcase/simple/pages/ArtifactEntry.java
  6. +32 −0 thucydides-showcase-simple-webtests/src/main/java/net/thucydides/showcase/simple/pages/SearchPage.java
  7. +40 −0 thucydides-showcase-simple-webtests/src/main/java/net/thucydides/showcase/simple/pages/SearchResultsPage.java
  8. +39 −0 ...ydides-showcase-simple-webtests/src/test/java/net/thucydides/showcase/simple/WhenSearchingForArtifacts.java
  9. +41 −0 ...dides-showcase-simple-webtests/src/test/java/net/thucydides/showcase/simple/WhenViewingArtifactDetails.java
  10. +16 −0 thucydides-showcase-simple-webtests/src/test/java/net/thucydides/showcase/simple/requirements/Application.java
  11. +62 −0 thucydides-showcase-simple-webtests/src/test/java/net/thucydides/showcase/simple/steps/DeveloperSteps.java
  12. +37 −0 ...des-showcase-simple-webtests/src/test/stories/net/thucydides/showcase/simple/SearchForArtifactsByName.story
  13. +38 −0 thucydides-showcase-simple-webtests/src/test/stories/net/thucydides/showcase/simple/ViewArtifactDetails.story
16 .gitignore
@@ -0,0 +1,16 @@
+.project
+.settings
+target
+.idea
+.classpath
+.checkstyle
+*.log
+*.log.*
+*.iml
+*.versionsBackup
+interpolated-*.xml
+*.iws
+*.ipr
+out
+.DS_Store
+*.ignore
15 thucydides-showcase-simple-webtests/.gitignore
@@ -0,0 +1,15 @@
+.project
+.settings
+target
+.idea
+.classpath
+.checkstyle
+*.log
+*.log.*
+*.iml
+*.versionsBackup
+interpolated-*.xml
+*.iws
+*.ipr
+out
+*.ignore
189 thucydides-showcase-simple-webtests/pom.xml
@@ -0,0 +1,189 @@
+<?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>net.thucydides.showcase</groupId>
+ <artifactId>thucydides-showcase-simple-webtests</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Sample Thucydides project</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <thucydides.version>0.4.30</thucydides.version>
+ <thucydides.easyb.version>0.4.30</thucydides.easyb.version>
+ <webdriver.driver>firefox</webdriver.driver>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>net.thucydides</groupId>
+ <artifactId>thucydides-core</artifactId>
+ <version>${thucydides.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>net.thucydides</groupId>
+ <artifactId>thucydides-junit</artifactId>
+ <version>${thucydides.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.thucydides.easyb</groupId>
+ <artifactId>thucydides-easyb-plugin</artifactId>
+ <version>${thucydides.easyb.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.8.2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.googlecode.lambdaj</groupId>
+ <artifactId>lambdaj</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-all</artifactId>
+ <version>1.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.9</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.10</version>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ <include>**/Test*.java</include>
+ <include>**/When*.java</include>
+ </includes>
+ <argLine>-Xmx512m</argLine>
+ <systemPropertyVariables>
+ <webdriver.driver>${webdriver.driver}</webdriver.driver>
+ <thucydides.browser.width>1000</thucydides.browser.width>
+ </systemPropertyVariables>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.easyb</groupId>
+ <artifactId>maven-easyb-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <storyType>html</storyType>
+ <storyReport>target/easyb/easyb.html</storyReport>
+ <easybTestDirectory>src/test/stories</easybTestDirectory>
+ <jvmArguments>-Xmx512m -Dwebdriver.driver=${webdriver.driver}</jvmArguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>net.thucydides.maven.plugins</groupId>
+ <artifactId>maven-thucydides-plugin</artifactId>
+ <version>${thucydides.version}</version>
+ <executions>
+ <execution>
+ <id>thucydides-reports</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>aggregate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>maven2</id>
+ <activation>
+ <file>
+ <missing>${basedir}</missing>
+ </file>
+ </activation>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>net.thucydides.maven.plugins</groupId>
+ <artifactId>maven-thucydides-plugin</artifactId>
+ <version>${thucydides.version}</version>
+ </plugin>
+ </plugins>
+ </reporting>
+ </profile>
+ <profile>
+ <id>maven3</id>
+ <activation>
+ <file>
+ <exists>${basedir}</exists>
+ </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.0-beta-3</version>
+ <configuration>
+ <reportPlugins>
+ <plugin>
+ <groupId>net.thucydides.maven.plugins</groupId>
+ <artifactId>maven-thucydides-plugin</artifactId>
+ <version>${thucydides.version}</version>
+ </plugin>
+ </reportPlugins>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
39 ...des-showcase-simple-webtests/src/main/java/net/thucydides/showcase/simple/pages/ArtifactDetailsPage.java
@@ -0,0 +1,39 @@
+package net.thucydides.showcase.simple.pages;
+
+import net.thucydides.core.matchers.PropertyMatcher;
+import net.thucydides.core.pages.PageObject;
+import net.thucydides.core.pages.WebElementFacade;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+
+import java.util.List;
+import java.util.Map;
+
+import static net.thucydides.core.pages.components.HtmlTable.filterRows;
+import static net.thucydides.core.pages.components.HtmlTable.rowsFrom;
+
+public class ArtifactDetailsPage extends PageObject {
+
+ WebElement groupid;
+ WebElement artifactid;
+ WebElement versionid;
+
+ public ArtifactDetailsPage(WebDriver driver) {
+ super(driver);
+ }
+
+ public String getGroupId() {
+ return element(groupid).getTextValue();
+ }
+
+ public String getArtifactId() {
+ return element(artifactid).getTextValue();
+ }
+
+ public String getVersionId() {
+ return element(versionid).getTextValue();
+ }
+}
+
+
25 thucydides-showcase-simple-webtests/src/main/java/net/thucydides/showcase/simple/pages/ArtifactEntry.java
@@ -0,0 +1,25 @@
+package net.thucydides.showcase.simple.pages;
+
+public class ArtifactEntry {
+ private final String groupId;
+ private final String artifactId;
+ private final String latestVersion;
+
+ public ArtifactEntry(String groupId, String artifactId, String latestVersion) {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.latestVersion = latestVersion;
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ public String getLatestVersion() {
+ return latestVersion;
+ }
+}
32 thucydides-showcase-simple-webtests/src/main/java/net/thucydides/showcase/simple/pages/SearchPage.java
@@ -0,0 +1,32 @@
+package net.thucydides.showcase.simple.pages;
+
+import net.thucydides.core.annotations.DefaultUrl;
+import net.thucydides.core.pages.PageObject;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+@DefaultUrl("http://search.maven.org/")
+public class SearchPage extends PageObject {
+
+
+ @FindBy(id="query")
+ private WebElement search;
+
+ @FindBy(id="queryButton")
+ private WebElement searchButton;
+
+ public SearchPage(WebDriver driver) {
+ super(driver);
+ }
+
+ public void enter_search_terms(String searchTerms) {
+ search.sendKeys(searchTerms);
+ }
+
+ public void starts_search() {
+ searchButton.click();
+ }
+}
+
+
40 ...dides-showcase-simple-webtests/src/main/java/net/thucydides/showcase/simple/pages/SearchResultsPage.java
@@ -0,0 +1,40 @@
+package net.thucydides.showcase.simple.pages;
+
+import net.thucydides.core.matchers.PropertyMatcher;
+import net.thucydides.core.pages.PageObject;
+import net.thucydides.core.pages.WebElementFacade;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+
+import java.util.List;
+import java.util.Map;
+
+import static net.thucydides.core.pages.components.HtmlTable.filterRows;
+import static net.thucydides.core.pages.components.HtmlTable.rowsFrom;
+
+public class SearchResultsPage extends PageObject {
+
+ WebElement resultTable;
+
+ public SearchResultsPage(WebDriver driver) {
+ super(driver);
+ }
+
+ public List<Map<String, String>> getSearchResults() {
+ return rowsFrom(resultTable);
+ }
+
+ public WebElementFacade resultTable() {
+ return element(resultTable);
+ }
+
+ public void clickOnFirstRowMatching(PropertyMatcher... matchers) {
+ List<WebElement> matchingRows = filterRows(resultTable, matchers);
+ WebElement targetRow = matchingRows.get(0);
+ WebElement detailsLink = targetRow.findElement(By.xpath(".//a[contains(@href,'artifactdetails')]"));
+ detailsLink.click();
+ }
+}
+
+
39 ...des-showcase-simple-webtests/src/test/java/net/thucydides/showcase/simple/WhenSearchingForArtifacts.java
@@ -0,0 +1,39 @@
+package net.thucydides.showcase.simple;
+
+import net.thucydides.core.annotations.Managed;
+import net.thucydides.core.annotations.ManagedPages;
+import net.thucydides.core.annotations.Steps;
+import net.thucydides.core.annotations.Story;
+import net.thucydides.core.pages.Pages;
+import net.thucydides.junit.runners.ThucydidesRunner;
+import net.thucydides.showcase.simple.requirements.Application;
+import net.thucydides.showcase.simple.steps.DeveloperSteps;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.WebDriver;
+
+import static net.thucydides.core.matchers.PropertyMatcher.the;
+import static org.hamcrest.Matchers.is;
+
+@RunWith(ThucydidesRunner.class)
+@Story(Application.Search.SearchForArtifactsByName.class)
+public class WhenSearchingForArtifacts {
+
+ @Managed
+ WebDriver driver;
+
+ @ManagedPages(defaultUrl = "http://search.maven.org")
+ public Pages pages;
+
+ @Steps
+ public DeveloperSteps developer;
+
+ @Test
+ public void should_search_for_artifacts_by_name() {
+ developer.opens_the_search_page();
+ developer.searches_for("Thucydides");
+ developer.should_see_artifacts_where(the("ArtifactId", is("thucydides")),
+ the("GroupId", is("net.thucydides")));
+
+ }
+}
41 ...es-showcase-simple-webtests/src/test/java/net/thucydides/showcase/simple/WhenViewingArtifactDetails.java
@@ -0,0 +1,41 @@
+package net.thucydides.showcase.simple;
+
+import net.thucydides.core.annotations.Managed;
+import net.thucydides.core.annotations.ManagedPages;
+import net.thucydides.core.annotations.Steps;
+import net.thucydides.core.annotations.Story;
+import net.thucydides.core.pages.Pages;
+import net.thucydides.junit.runners.ThucydidesRunner;
+import net.thucydides.showcase.simple.requirements.Application;
+import net.thucydides.showcase.simple.steps.DeveloperSteps;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.WebDriver;
+
+import static net.thucydides.core.matchers.PropertyMatcher.the;
+import static org.hamcrest.Matchers.is;
+
+@RunWith(ThucydidesRunner.class)
+@Story(Application.DisplayArtifacts.ViewArtifactDetails.class)
+public class WhenViewingArtifactDetails {
+
+ @Managed
+ WebDriver driver;
+
+ @ManagedPages(defaultUrl = "http://search.maven.org")
+ public Pages pages;
+
+ @Steps
+ public DeveloperSteps developer;
+
+ @Test
+ public void clicking_on_artifact_should_display_details_page() {
+ developer.opens_the_search_page();
+ developer.searches_for("Thucydides");
+ developer.open_artifact_where(the("ArtifactId", is("thucydides")),
+ the("GroupId", is("net.thucydides")));
+
+ developer.should_see_artifact_details_where(the("artifactId", is("thucydides")),
+ the("groupId", is("net.thucydides")));
+ }
+}
16 ...ides-showcase-simple-webtests/src/test/java/net/thucydides/showcase/simple/requirements/Application.java
@@ -0,0 +1,16 @@
+package net.thucydides.showcase.simple.requirements;
+
+import net.thucydides.core.annotations.Feature;
+
+public class Application {
+ @Feature
+ public class Search {
+ public class SearchForArtifactsByName {}
+ public class AdvancedSearch {}
+ }
+
+ @Feature
+ public class DisplayArtifacts {
+ public class ViewArtifactDetails {}
+ }
+}
62 thucydides-showcase-simple-webtests/src/test/java/net/thucydides/showcase/simple/steps/DeveloperSteps.java
@@ -0,0 +1,62 @@
+package net.thucydides.showcase.simple.steps;
+
+import net.thucydides.core.annotations.Step;
+import net.thucydides.core.matchers.PropertyMatcher;
+import net.thucydides.core.pages.Pages;
+import net.thucydides.core.steps.ScenarioSteps;
+import net.thucydides.showcase.simple.pages.ArtifactDetailsPage;
+import net.thucydides.showcase.simple.pages.SearchPage;
+import net.thucydides.showcase.simple.pages.SearchResultsPage;
+
+import static net.thucydides.core.matchers.PropertyMatcher.shouldMatch;
+
+public class DeveloperSteps extends ScenarioSteps {
+
+ public DeveloperSteps(Pages pages) {
+ super(pages);
+ }
+
+ @Step
+ public void opens_the_search_page() {
+ onSearchPage().open();
+ }
+
+ @Step
+ public DeveloperSteps searches_for(String search_terms) {
+ onSearchPage().enter_search_terms(search_terms);
+ onSearchPage().starts_search();
+ return this;
+ }
+
+ @Step
+ public void should_see_artifacts_where(PropertyMatcher... matchers) {
+ shouldMatch(onSearchResultsPage().getSearchResults(), matchers);
+ }
+
+ @Step
+ public void should_see_error_message(String expectedMessage) {
+ onSearchResultsPage().resultTable().shouldContainText(expectedMessage);
+ }
+
+ @Step
+ public void open_artifact_where(PropertyMatcher... matchers) {
+ onSearchResultsPage().clickOnFirstRowMatching(matchers);
+ }
+
+ @Step
+ public void should_see_artifact_details_where(PropertyMatcher... matchers) {
+ shouldMatch(onArtifactDetailsPage(), matchers);
+ }
+
+ private SearchPage onSearchPage() {
+ return getPages().get(SearchPage.class);
+ }
+
+ private SearchResultsPage onSearchResultsPage() {
+ return getPages().get(SearchResultsPage.class);
+ }
+
+ private ArtifactDetailsPage onArtifactDetailsPage() {
+ return getPages().get(ArtifactDetailsPage.class);
+ }
+}
37 ...-showcase-simple-webtests/src/test/stories/net/thucydides/showcase/simple/SearchForArtifactsByName.story
@@ -0,0 +1,37 @@
+package net.thucydides.showcase.simple
+
+import net.thucydides.showcase.simple.requirements.Application.Search.SearchForArtifactsByName
+import net.thucydides.showcase.simple.steps.DeveloperSteps
+import static net.thucydides.core.matchers.PropertyMatcher.the
+import static org.hamcrest.Matchers.is
+
+using "thucydides"
+
+thucydides.uses_default_base_url "http://search.maven.org"
+thucydides.tests_story SearchForArtifactsByName
+thucydides.uses_steps_from DeveloperSteps
+
+scenario "A developer looks for an existing Maven artifact by name and group id", {
+ given "the developer is on the Maven Central search page", {
+ developer.opens_the_search_page()
+ }
+ when "the user searches for artifacts with the name 'thucydides'", {
+ developer.searches_for 'Thucydides'
+ }
+ then "the thucyidides core artifact should appear in the results list", {
+ developer.should_see_artifacts_where( the("ArtifactId", is("thucydides")),
+ the("GroupId", is("net.thucydides")))
+ }
+}
+
+scenario "A developer looks for an inexistant Maven artifact by name", {
+ given "the developer is on the Maven Central search page", {
+ developer.opens_the_search_page()
+ }
+ when "the user searches for artifacts with the name 'thucydides'", {
+ developer.searches_for 'does-not-exist'
+ }
+ then "the thucyidides core artifact should appear in the results list", {
+ developer.should_see_error_message "No records found"
+ }
+}
38 ...dides-showcase-simple-webtests/src/test/stories/net/thucydides/showcase/simple/ViewArtifactDetails.story
@@ -0,0 +1,38 @@
+package net.thucydides.showcase.simple
+
+import net.thucydides.showcase.simple.requirements.Application.DisplayArtifacts
+import net.thucydides.showcase.simple.steps.DeveloperSteps
+import static net.thucydides.core.matchers.PropertyMatcher.the
+import static org.hamcrest.Matchers.is
+
+using "thucydides"
+
+//thucydides.uses_default_base_url "http://search.maven.org"
+thucydides.tests_story DisplayArtifacts.ViewArtifactDetails
+thucydides.uses_steps_from DeveloperSteps
+
+scenario "A developer views the details of for an existing Maven artifact", {
+ given "the developer is on the Maven Central search page", {
+ developer.opens_the_search_page()
+ }
+ and "the user searches for artifacts with the name 'thucydides'", {
+ developer.searches_for 'Thucydides'
+
+ }
+ and "the user clicks on the first Thucydides artifact", {
+ developer.open_artifact_where(the("ArtifactId", is("thucydides")),
+ the("GroupId", is("net.thucydides")));
+ }
+ then "the site should display details about the Thucydides artifact", {
+ developer.should_see_artifact_details_where(the("artifactId", is("thucydides")),
+ the("groupId", is("net.thucydides")));
+
+ }
+}
+
+scenario "The developer views a sample pom.xml dependency for the artifact", {
+ given "the developer is on the Maven Central search page"
+ and "the user searches for artifacts with the name 'thucydides'"
+ and "the user clicks on the first Thucydides artifact"
+ then "the site should display a sample XML dependency for this artifact"
+}
Please sign in to comment.
Something went wrong with that request. Please try again.