Project to demonstrate my automation testing skills in Java, as part of my 2019 job search for SDET positions.
This suite of test cases runs against an example Wordpress site. It uses Wordpress REST API endpoints to retrieve data about the test site, and analyzes JSON payloads returned by these endpoints.
In Phase 1 of this demo, I am working with the endpoints that provide publicly available data, such as the posts, categories, tags, and pages visible on the site.
To run this suite, I set up a test Wordpress site using Docker Compose. You can see the wp-docker-compose.yml file I use to set up the containers on my misc-configs repo.
I also add aliases for wordpress.local and phpmyadmin.local to my hosts file, so that those URLs will work as the automation runs.
The test data I'm using is a copy of one of my live Wordpress sites, which has provided me the items to fill in for my properties file.
The main tool I'm using to run the suite is IntelliJ. The IML file for IntelliJ is included in this repo, as well as the pom.xml, as this is set up as a Maven project. I use the Unirest library to hit the Wordpress endpoints.
Dependencies included in the POM are:
- org.apache.maven.plugins (for Surefire, and exclusion to force use of log4j 2)
- org.apache.log4j (version 2)
Dependencies in the POM were last updated as of 7/3/2020.
Skills and tech I'm demonstrating here
- Use of a properties file to set test-specific strings like ID numbers, titles, and names
- Using the Unirest library to hit the service endpoints
- Using the org.json classes to process JSON payloads
- Using TestNG functionality to run the test suite, and to annotate test methods
- Use of a POM file to set Maven dependencies and to run the test suite via Maven as well as TestNG
- Testing against a site running as a Docker container
- Use of Log4j to do basic logging
- Negative as well as positive test cases for the various endpoints
Running the code yourself
If you'd like to try running this suite yourself, you will need to do the following:
- Install IntelliJ IDEA if you don't have it already.
- Install Docker if you don't have it already.
- Install git if you don't have it already.
- Edit your local hosts file to add aliases for wordpress.local to 127.0.0.1 (and phpmyadmin.local if you're using my PHPMyAdmin container).
- Create a local Wordpress instance with Docker (see my misc-configs repo for a wp-docker-compose.yml you can use as a reference, and modify as appropriate for your testing).
- Configure your local Wordpress with whatever test data you want to use. This may involve importing data of your own in from another site, or otherwise generating test posts, pages, etc. via whatever means you have available.
- Check out this repo on your own system.
- Import the project into your IntelliJ.
- In IntelliJ, use the testng.xml file to create a configuration you can use to run the test cases. It's a suite file, so you'll want to choose "Suite" in the configuration settings. All other settings can remain as default.
- Open the wp-test-demo.properties file and edit it as appropriate to reflect what test data you're using.
- If you use my Postman collection and environment, you should also tweak the environment settings to reflect your test data. The environment file should match what you put into the properties file in IntelliJ.
Running the code on a Linux environment
This code has been successfully most recently run against IntelliJ Community Edition 2020.1.2, on an Ubuntu Linux install (Ubuntu 20.04 LTS) with OpenJDK version 1.8 installed.
Running the code on a Windows 10 environment
If you want to run this demo on Windows 10, you may need to take additional steps depending on whether you're using the Windows 10 Linux subsystem. See the tutorial link I include in the reference links below.
My Windows 10 setup for this demo includes running the Docker containers within the Linux subsystem. My Windows IntelliJ can't see the subsystem, so on this environment, I also installed Cygwin (with git) to do my code checkout in a place where IntelliJ could see it.
- Misc-configs repo where I have my Docker Compose file for a test Wordpress site, and my Postman files
- Unirest, the Java library I'm using to do the REST calls
- Wordpress REST API, reference source for the endpoints I use in this demo
- Setting Up Docker for Windows and WSL to Work Flawlessly, tutorial I followed to set up Docker to run on the Windows 10 partition of my dev box