This is a Maven project that has Cucumber tests that validates a DVD rental business data using the following technologies:
- Apache
- Commons
- Lang3
- Cucumber
- Gherkin
- Gson
- Java 1.8
- Maven
- PostgreSQL
- TestNG
There are two queries that are developed and then executed in the database. The first query extrapolates all the revenue that has been generated by country. The second query creates a user segment such that all United States customers that have paid less than the average amount are retrieved. The results are returned in a JSON array, and the acceptance criteria in the .feature file are validated. The developed SQL queries can be found at src/test/resources/sql_queries.
- Install Java 1.8 or higher.
- Install Maven.
- Install PostgreSQL (ensure to install pgAdmin as well).
- If the PgAdmin app also gets installed, go through it, but remember to note down the password used for the setup.
- Clone this repository.
- The following are a set of steps to setup the DVD Rental DB. This needs to be done only once.
- Start the PostgreSQL service (if not done so already).
- Invoke the app, "pgAdmin".
- This can be done by typing "pgadmin" in the Terminal or Command Prompt. In Windows, this can be accessed by clicking on the "pgAdmin" icon in the "Postgres" directory.
- Note down the port value (by default it is 5432).
- Click on Add Server or Add Connection at the top.
- Populate "Host" as "localhost".
- Populate "Port" as "5432".
- Populate "Username" as "postgres".
- Populate "Password" as the value noted down in step 3.i.
- If no password was set, then leave it blank.
- Alternatively, a new password can be setup by doing the following:
- Access Terminal or Command Prompt.
- Execute the command "psql".
- Execute the command, "\password".
- Type a new password. Press Enter.
- Retype the new password. Press Enter.
- This new password can now be used in step 5.ii.g.
- Click OK. The "localhost" connection will now be operational.
- In pgAdmin, double click on the "localhost" connection.
- Right click on "Databases".
- Select "New Database".
- Type "dvdrental" as the database name.
- Click OK.
- Right click the "dvdrental" database.
- Select "Restore". The "Restore database 'dvdrental'" dialog box will appear.
- Click on the "..." button.
- Navigate to the path [location where the repository was cloned in step 4]/db/dvdrental.tar.
- Click on the file, "dvdrental.tar".
- Click "Restore".
- Ignore the errors, and move on to the next step.
- Open up Terminal/Command Prompt, navigate to this project, and then execute the following command:
- mvn clean test -Dhost=localhost -DdbName=dvdrental -DdbPort=[port where the PostgreSQL database is setup] -DdbUsername=[The admin username of the local PostgreSQL setup] -DdbPwd=[The admin password of the local PostgreSQL setup]
- Example: mvn clean test -Dhost=localhost -DdbName=dvdrental -DdbPort=5432 -DdbUsername=postgres -DdbPwd=admin
- mvn clean test -Dhost=localhost -DdbName=dvdrental -DdbPort=[port where the PostgreSQL database is setup] -DdbUsername=[The admin username of the local PostgreSQL setup] -DdbPwd=[The admin password of the local PostgreSQL setup]
- The reports can be found at the following locations:
- Cucumber HTML Report: target/cucumber-html-report/index.html
- Note: This report only contains BDD data and no logs.
- Cucumber TestNG Report: target/surefire-reports/Cucumber_TestNG Runner
- Note: This report contains both BDD and logs reporting, which therefore makes it the best report for viewing
- TestNG Report: target/surefire-reports/emailable-report.html
- Note: This report only has test report logs.
- Cucumber HTML Report: target/cucumber-html-report/index.html