Skip to content
/ bdd-db Public

A BDD Maven project that integrates Cucumber, Maven, PostgreSQL DB, and TestNG

Notifications You must be signed in to change notification settings

shiraz/bdd-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL Database Behavior Driven Development Project

Project Description:

This is a Maven project that has Cucumber tests that validates a DVD rental business data using the following technologies:

  1. Apache
    1. Commons
    2. Lang3
  2. Cucumber
  3. Gherkin
  4. Gson
  5. Java 1.8
  6. Maven
  7. PostgreSQL
  8. TestNG

Tests Description:

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.

Steps to Execute Tests:

  1. Install Java 1.8 or higher.
  2. Install Maven.
  3. Install PostgreSQL (ensure to install pgAdmin as well).
    1. If the PgAdmin app also gets installed, go through it, but remember to note down the password used for the setup.
  4. Clone this repository.
  5. The following are a set of steps to setup the DVD Rental DB. This needs to be done only once.
    1. Start the PostgreSQL service (if not done so already).
    2. Invoke the app, "pgAdmin".
      1. 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.
      2. Note down the port value (by default it is 5432).
      3. Click on Add Server or Add Connection at the top.
      4. Populate "Host" as "localhost".
      5. Populate "Port" as "5432".
      6. Populate "Username" as "postgres".
      7. Populate "Password" as the value noted down in step 3.i.
        1. If no password was set, then leave it blank.
        2. Alternatively, a new password can be setup by doing the following:
          1. Access Terminal or Command Prompt.
          2. Execute the command "psql".
          3. Execute the command, "\password".
          4. Type a new password. Press Enter.
          5. Retype the new password. Press Enter.
          6. This new password can now be used in step 5.ii.g.
      8. Click OK. The "localhost" connection will now be operational.
      9. In pgAdmin, double click on the "localhost" connection.
      10. Right click on "Databases".
      11. Select "New Database".
      12. Type "dvdrental" as the database name.
      13. Click OK.
      14. Right click the "dvdrental" database.
      15. Select "Restore". The "Restore database 'dvdrental'" dialog box will appear.
      16. Click on the "..." button.
      17. Navigate to the path [location where the repository was cloned in step 4]/db/dvdrental.tar.
      18. Click on the file, "dvdrental.tar".
      19. Click "Restore".
      20. Ignore the errors, and move on to the next step.
  6. Open up Terminal/Command Prompt, navigate to this project, and then execute the following command:
    1. 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]
      1. Example: mvn clean test -Dhost=localhost -DdbName=dvdrental -DdbPort=5432 -DdbUsername=postgres -DdbPwd=admin
  7. The reports can be found at the following locations:
    1. Cucumber HTML Report: target/cucumber-html-report/index.html
      1. Note: This report only contains BDD data and no logs.
    2. Cucumber TestNG Report: target/surefire-reports/Cucumber_TestNG Runner
      1. Note: This report contains both BDD and logs reporting, which therefore makes it the best report for viewing
    3. TestNG Report: target/surefire-reports/emailable-report.html
      1. Note: This report only has test report logs.

About

A BDD Maven project that integrates Cucumber, Maven, PostgreSQL DB, and TestNG

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published