Public Repository

Last pushed: 5 months ago
Short Description
Testing Wikipedia navitgation with Geb+Spock+PhantomJS. Page Object pattern and BDD fashion.
Full Description

Test Automation, Wikipedia Navigation Example

This is a simple test that will navigate throught Wikipedia. To launch it, with Docker installed and ready, just run:

  • docker run -t gopejavi/geb-wiki-example

There is no need to execute any additional command for running the tests, as Docker takes care of that.
If you want to check how the tests have been made (including Page Object pattern) you can check it at
https://github.com/gopejavi/GebExampleToTest/tree/master/src/test/groovy
where the file WikipediaTestSpec.groovy is the test entry point.

How Was Implemented

Basic steps taken:

  1. I donwloaded a Linux VM (next actions are done there).
  2. I learned basics for Docker and installed it.
  3. I studied the Page Object pattern.
  4. Then I learned how Geb works and how Spock lets us define tests in a BDD fashion.
  5. From Geb official repository, I downloaded a working example for Docker as a starting point. I modified it to only use the headless PhantomJS browser for better speed.
  6. Then I implemented the WikiTestSpec base.
  7. Finally, I modelized the different pages:
    • Pages are modelized into files ending with "Page"
    • Page pieces or sections are modelized into files ending with "Module".
    • Modules are reused in Pages. For example, the english main Wikipedia page and MVVM page share the basic definitions for header and footer.
    • I consider the header as correct if it has the personal area section within.
    • I consider the footer as correct if it talks about the Creative Commons license somewhere.

Dockerfile

Although there's no need to use it, I included it as is not in the tests repository and is part of the work:

# Easily run tests with Geb, Spock and PhantomJS
FROM ubuntu:latest

RUN apt-get update && apt-get install -y \
    wget \
    unzip \
    git \
    default-jre \
&& rm -rf /var/lib/apt/lists/*
#last line cleans apt cache so reduces Docker image size.

# Gradle
WORKDIR /usr/bin
RUN wget https://services.gradle.org/distributions/gradle-4.0-all.zip && \
  unzip gradle-4.0-all.zip && \
  ln -s gradle-4.0 gradle && \
  rm gradle-4.0-all.zip
ENV GRADLE_HOME /usr/bin/gradle
#RUN chmod +x /usr/bin/gradle
ENV PATH $PATH:$GRADLE_HOME/bin
# Put Gradle cache in /var so it can it is part of container
ENV GRADLE_USER_HOME /var/cache/gradle

# Prime the Gradle cache with dependencies needed to run simple Geb scripts
WORKDIR /root
RUN git clone https://github.com/gopejavi/GebExampleToTest.git
WORKDIR GebExampleToTest

#So it is faster when actually running, as dependencies are already in Docker image (has to be improved)
RUN ./gradlew phantomJsTest

#Output some info in the case some error happens
CMD ./gradlew phantomJsTest --info
Docker Pull Command
Owner
gopejavi