Sunday, 24 November 2019

Rest Assured: Set up the project to test


Prerequisite:
Install git in your system


Step 1: Clone the repository ‘https://github.com/harikrishna553/restAssured.git’.

$git clone https://github.com/harikrishna553/restAssured.git
Cloning into 'restAssured'...
remote: Enumerating objects: 24, done.
remote: Counting objects: 100% (24/24), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 24 (delta 1), reused 24 (delta 1), pack-reused 0
Unpacking objects: 100% (24/24), done.


‘restAssured’ directory structure looks like below.
$tree restAssured
restAssured
├── pom.xml
└── src
    └── main
        └── java
            └── com
                └── sample
                    └── app
                        ├── App.java
                        ├── controller
                        │   └── EmployeeController.java
                        ├── model
                        │   └── Employee.java
                        └── util
                            └── EmployeeUtil.java

9 directories, 5 files

Step 2: Navigate to the directory where pom.xml file is present and execute ‘mvn package’ command.


Once you execute ‘mvn package’ command, it generate a jar file in ‘target’ folder.
$ tree
.
├── pom.xml
├── src
│   └── main
│       └── java
│           └── com
│               └── sample
│                   └── app
│                       ├── App.java
│                       ├── controller
│                       │   └── EmployeeController.java
│                       ├── model
│                       │   └── Employee.java
│                       └── util
│                           └── EmployeeUtil.java
└── target
    ├── classes
    │   └── com
    │       └── sample
    │           └── app
    │               ├── App.class
    │               ├── controller
    │               │   └── EmployeeController.class
    │               ├── model
    │               │   └── Employee.class
    │               └── util
    │                   └── EmployeeUtil.class
    ├── generated-sources
    │   └── annotations
    ├── maven-archiver
    │   └── pom.properties
    ├── maven-status
    │   └── maven-compiler-plugin
    │       └── compile
    │           └── default-compile
    │               ├── createdFiles.lst
    │               └── inputFiles.lst
    ├── restassured-1.jar
    └── restassured-1.jar.original

24 directories, 14 files

Navigate to the directory where jar file is located and execute below command.
java -jar restassured-1.jar --server.port=8080


Open the url 'http://localhost:8080/api/v1/employees' in browser, you will see below kind of response.


Previous                                                    Next                                                    Home

No comments:

Post a Comment