Comments automated tests
This repo provides a sample set of automated tests for http://commentssprintone.azurewebsites.net application.
- Java 8 as a programming language
- maven as a build system
- Allure as a reporting engine
- Selenium as a WEB automation framework
- TestNG as a tests runner
- Sunshine as a suite manager for TestNG
- Docker as an infrastructure manager
- SeleniumHQ/docker-selenium as a Selenium Grid
Running the tests
There are two supported browsers:
The tests are going to connect to a remote driver. It can be either a WebDriver run as a standalone process or Selenium Grid.
Using docker's image
First of all, you need to run desired WebDriver (
geckodriver) as a standalone application (instructions for
ChromeDriver). If you have a working Selenium Grid, you can use it instead.
Then, run the following command with the correct value for
BROWSER (see configuration options for the details):
docker run -it \ --net=host \ --env SELENIUM_URL=http://docker.for.mac.localhost:4444 \ --env BROWSER=firefox \ --volume $(pwd)/allure-results:/jcat/allure-results \ extsoft/jcat:latest
SELENIUM_URL option. Docker provides several networking features for each OS which allow binding of host machine's hostname into a container. As the result, if you bind a container to host's network with
--net=host and want access host's resources, correct hostname is
--net=<Selenium Grid network> to the command above.
To be able to use this type of run, you need to have Docker engine release
1.13.0+. A simple way to check:
First of all, you need to download a YAML file:
curl -o docker-compose.yaml https://raw.githubusercontent.com/extsoft/jcat/master/docker-compose.yaml
Then, run tests:
docker-compose up --abort-on-container-exit --timeout 120
chrome browsers and executes the tests in parallel. If you need one of browsers, add
jcat-on-chrome to the end of the command.
After the tests execution, the Allure results directories are created:
If you need Selenium Grid for development purposes, run
docker-compose up -d firefox60 chrome66. As the Grid's port is mapped to a host machine, you view Grid's console on http://localhost:4444/grid/console.
docker-compose down to destroy the environment.
From source code
- Clone the repo
- Package tests with
mvn clean package(a JAR file is located under
targetdirectory and is named like
versionproperty from pom.xml).
- Run tests with
java -jar comments-at-x.x.x-jar-with-dependencies.jar
java -Dbrowser=firefox -Dselenium-url=http://127.0.0.1:4444 \ -jar comments-at-0.1.0-jar-with-dependencies.jar
runs tests on Firefox browser using
geckodriver started on
|Environment variable (Docker)||System property (Java)||Options||Default value (Docker / Java)||Description|
||A browser for testing|
||Any remote URL||
||An URL to remove driver or Selenium Grid|
The Allure files are stored to
allure-results directory within the directory where you run the tests. Just run
allure serve to see the Allure HTML report.