Demandware Automated Testing Framework

The purpose of this framework is to minimize the amount of bolierplate code required to test Demandware Site Genesis 2.0 implementations. The goal of the framework is to establish a base level of testing flows for Site Genesis 2.0, provide re-usable and extensible Page/Module objects and the mechanisms to extend the framework for deviations from Site Genesis 2.0

Back To Top

Overview

This documentation will cover what and why specific technology has been implemented and how to use the framework to add automated testing to a Demandware project

Technologies

  • Spock - Spock is a BDD Specification testing framework that works with JUnit. Spock's Specifications are the base of this framework's test cases. Spock Documentation
  • Geb - Geb is a groovy based abstraction of WebDriver with a focus on simplistic syntax and easy encapsulations. Geb Documentation.
  • WebDriver - WebDriver is the successor to Selenium RC. WebDriver utilizes small applications to "Drive" a browser instead of attempting to control the mouse.
  • Maven 3 - Maven is the leading Java based build tool. Maven simplifies dependency management and enforces a consistent project structure
  • Bamboo - Bamboo is a Continuous Integration environment from Atlassian. If you do not have the means to build an infrastructure, check out On-Demand for an in-cloud based CI environment. Bamboo OnDemand Homepage
  • SauceLabs - SauceLabs is a cloud-based Remote Web Driver which allows for a combined 96+ browser/OS testing matrix without changing the codebase. SauceLabs Homepage
Back To Top

Prerequisites

In order to use and extend this framework, the following must be installed and working correctly:

Required Tools

Optional Tools

The following are optional but useful tools when working with Git:

Back To Top

How to Use

After all of the prerequisites have been met, tests may be initiated from an IDE (Eclipse or IntelliJ) or via Maven command-line prompt.

Run Tests (Command Line)

Run the Maven "test" phase from the command line:

 mvn clean test 
Should produce something similar to:
user@computer ~/projects/demandware-testing-framework (master)
$ mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building demandware-testing-framework 0.01-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ demandware-testing-framework ---
[INFO] Deleting c:\Users\user\projects\demandware-testing-framework\target
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (enforce-property) @ demandware-testing-framework ---
[INFO]
[INFO] --- gmaven-plugin:1.5:generateStubs (default) @ demandware-testing-framework ---
[INFO] Generated 40 Java stubs
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demandware-testing-framework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 42 resources
[INFO] Copying 1 resource
[INFO]
[INFO] --- jrebel-maven-plugin:1.1.3:generate (generate-rebel-xml) @ demandware-testing-framework ---
[INFO] Processing com.acquitygroup.demandware:demandware-testing-framework with packaging jar
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ demandware-testing-framework ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 43 source files to c:\Users\user\projects\demandware-testing-framework\target\classes
[INFO]
[INFO] --- gmaven-plugin:1.5:compile (default) @ demandware-testing-framework ---
[INFO] Compiled 240 Groovy classes
[INFO]
[INFO] --- gmaven-plugin:1.5:generateTestStubs (default) @ demandware-testing-framework ---
[INFO] Generated 15 Java stubs
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ demandware-testing-framework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 15 resources
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ demandware-testing-framework ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 15 source files to c:\Users\user\projects\demandware-testing-framework\target\test-classes
[INFO]
[INFO] --- gmaven-plugin:1.5:testCompile (default) @ demandware-testing-framework ---
[INFO] Compiled 30 Groovy classes
[INFO]
[INFO] --- maven-surefire-plugin:2.13:test (default-test) @ demandware-testing-framework ---
[INFO] Surefire report directory: c:\Users\user\projects\demandware-testing-framework\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.acquitygroup.webtest.flow.GuestCheckoutWebFlow
Started ChromeDriver
port=25195
version=26.0.1383.0
log=c:\Users\user\projects\demandware-testing-framework\chromedriver.log
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 50.753 sec

Results :

Tests run: 9, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:07.979s
[INFO] Finished at: Sat Feb 23 17:28:55 PST 2013
[INFO] Final Memory: 37M/341M
[INFO] ------------------------------------------------------------------------

user@computer ~/projects/demandware-testing-framework (master)
$

Run One or more Test (IDE)

  1. Open the Specification/TestCase you want to run
  2. Right-click on/in the file and select "Run-As JUnit"
  3. NOTE: For Eclipse: Use the @IgnoreRest to annotate the single feature to test in the specification
  4. NOTE: IntelliJ: To run a single feature , put the cursor inside of the method and hit "ctrl+shift+F10" to create a new run-configuration specifying the single feature
Back To Top

Development Setup

Environment Properties | Required Properties | Optional Properties | How-To

This project requires Java 1.7 and Maven 3.0.3+ in order to build and run the test cases. Both are expected to be available on the PATH and have their appropriate environment variables defined. Follow the directions below if the target machine does not meet these requirements

  1. Install and configure Java 1.7 - Directions
  2. Install Maven 3 - Directions
  3. Eclipse
    1. Install egit plugin - Directions
    2. Install "Groovy-Eclipse" plugin - Directions
  4. IntelliJ 11+ - Nothing special to do (IntelliJ Rocks!!)
  5. Clone the Demandware Testing Framework repository: git@bitbucket.org:mikeensor/demandware-testing-framework.git
    • Command line (simplest):
      cd <where you want to put the repository>
      git clone git@bitbucket.org:mikeensor/demandware-testing-framework.git 
    • Both IDEs provide a mechanism to clone the repository. NOTE: If using Eclipse, follow the Eclipse Setup instructions to create the Eclipse .project file prior to importing existing project into Eclipse.

Back To Top

Configuration Variables

Configuration variables are used to expose specific configuration points within the testing framework allowing for flexibility when using the testing framework. Configuration variables are implemented by first checking for an Environment Variable, then an Environment Property. If neither exist, the build will fail for required environment properties

Remote Configuration (Saucelabs)

When running tests on SauceLabs a set of special environment properties are expected to configure the RemoteDriver object. There are two required environment proeprties comprising the credentials and one optional property to name the job for debugging.

Required Environment Properties

Variable Description Requred Scope/Use Type
saucelabs.username Username for SauceLabs account Remote Sessions String
saucelabs.password API Key/Passphrase for SauceLabs account. Passphrase located on the account page for Sauce Labs user Remote Sessions String
DW_CLIENT_PASSWORD Client ID matching OCAPI configuration OCAPI Enabled Services String
WEBDRIVER_HOME File path location to Chrome Driver on local system Local sessions String
webdriver.chrome.driver Alias for WEBDRIVER_HOME Local sessions String

Optional Environment Variables

Variable Description Requred Scope/Use Type
saucelabs.jobname Provide a name for SauceLabs to name the running instance (eg: BUILD_12345) Remote Sessions String
logging.webtest.level Enables command-line level changes to the logging levels of web tests. Values can be: debug, info, warn, error Anytime String
Back To Top

Environment Configuration How-To

Command Line Variables

The framework exposes some configuration changes to occur on a single run basis. These commands are sent in via standard Java command line properties

java -Dproperty.name=propertyValue -DsecondProperty=propertyValue
Back To Top

Appendix

Specification
A grouping of Features that comprise a Test Case. Specifications per Spock and this framework are a Test Case file using the pattern "*Specification.grooyv"
Feature
A feature is a single test within a Specification. In Spock and this framework, a feature is a method inside of a Specification file
Back To Top