API validation on Deck Of Cards application http://deckofcardsapi.com/
- java IDE (ex: eclipse)
- Maven configured.
- Preferably testNG plug-in configured on your IDE for execution.
- Clone this repo on to your local system.
- Open your IDE (like eclipse) and import the project as Maven -> Existing Maven Projects -- This is going to take little time to download missing artifacts and configure -- Make sure your IDE is using correct version of JDK (1.8)
- Run testng.xml file at root directory.
All the tests are located under package core.tests
Each REST endpoint has its own class (Tests file) unless if there are similar to each other.
Example: Add and Shuffle card piles are merged to a single Tests file.
core.library package currently has only one class CardsClient. This client is responsible for making the end calls to application. Headers, authentication, baseURLs should be handled here if they are required in future. Also general assertions can be added here to like checking for 5XX response codes and timeouts.
All tests will make use of this class methods instead of directly calling RestAssured methods. (This is to remove direct dependency of REST library in the tests)
Individual tests files get their own assert methods implemented from a Interface.
This helps in properly planning and asserting the response of a particular REST call.
We can also add a grouping feature here where a method will provide a set of assertions. This helps in future if we need to add a particular assertion to all tests.
Goal in this sample project is to demostrate that tests should be independent of libraries we use.
Ex: If in future, I want to use a different library to make REST calls, we can update the CardsClient. Similarly, Assert library can be easily modified without any changes to test classes.