Commit 11d06dfa authored by Training Purpose's avatar Training Purpose

Allure Report Integration

parent 4d3d8096
...@@ -12,8 +12,9 @@ ...@@ -12,8 +12,9 @@
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>4.8.1</cucumber.version> <!-- <cucumber.version>4.8.1</cucumber.version>-->
<aspectj.version>1.8.10</aspectj.version>
<allure.version>2.10.0</allure.version>
</properties> </properties>
...@@ -41,29 +42,66 @@ ...@@ -41,29 +42,66 @@
<version>1.3.1</version> <version>1.3.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>io.cucumber</groupId>--> <!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-junit4 -->
<!-- <artifactId>cucumber-core</artifactId>--> <dependency>
<!-- <version>${cucumber.version}</version>--> <groupId>io.qameta.allure</groupId>
<!-- </dependency>--> <artifactId>allure-junit4</artifactId>
<!-- <dependency>--> <version>${allure.version}</version>
<!-- <groupId>io.cucumber</groupId>--> </dependency>
<!-- <artifactId>cucumber-junit</artifactId>-->
<!-- <version>${cucumber.version}</version>--> <dependency>
<!-- </dependency>--> <groupId>io.qameta.allure</groupId>
<artifactId>allure-java-commons</artifactId>
<version>${allure.version}</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-model</artifactId>
<version>${allure.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<testResources> <testResources>
<testResource> <testResource>
<directory>src/test/java</directory> <directory>src/test/java</directory>
<filtering>true</filtering>
<excludes> <excludes>
<exclude>**/*.java</exclude> <exclude>**/*.java</exclude>
</excludes> </excludes>
</testResource> </testResource>
</testResources> </testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<properties>
<property>
<name>listener</name>
<value>io.qameta.allure.junit4.AllureJunit4</value>
</property>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build> </build>
</project> </project>
\ No newline at end of file
...@@ -5,71 +5,73 @@ Feature: First Sample API Test ...@@ -5,71 +5,73 @@ Feature: First Sample API Test
* header Accept = 'application/json' * header Accept = 'application/json'
* def req_payload = read('request.json') * def req_payload = read('request.json')
Scenario: First Get Call @nazoor
Given path '/users?page=2' Scenario: First Get Call
When method GET Given path '/users?page=2'
Then status 200 When method GET
Then status 200
Scenario: Demo Get call 1 @nazoor
Given path '/users' Scenario: Demo Get call 1
When param page = 2 Given path '/users'
When method GET When param page = 2
Then status 200 When method GET
And print response Then status 200
And print responseHeaders And print response
And print responseStatus And print responseHeaders
And print responseTime And print responseStatus
And print responseTime
Scenario: Demo Get Call 2 Scenario: Demo Get Call 2
Given path '/users' Given path '/users'
When param page = 2 When param page = 2
When method GET When method GET
Then status 200 Then status 200
And print response And print response
Then assert response.data[0].first_name == 'Michael' Then assert response.data[0].first_name == 'Michael'
Then match response.data[0].first_name == 'Michaelq' Then match response.data[0].first_name == 'Michaelq'
Scenario: Demo Post Call 1 Scenario: Demo Post Call 1
Given path '/users' Given path '/users'
And request {"name": "nazoor","job": "leader"} And request {"name": "nazoor","job": "leader"}
When method POST When method POST
Then status 201 Then status 201
Then print response Then print response
And match response == { "name": "nazoor","job": "leader","id": "#string","createdAt": "#ignore"} And match response == { "name": "nazoor","job": "leader","id": "#string","createdAt": "#ignore"}
Scenario: Demo Post Call 2 Scenario: Demo Post Call 2
Given path '/users' Given path '/users'
And request req_payload And request req_payload
When method POST When method POST
Then status 201 Then status 201
Then print response Then print response
And def exp_payload = karate.properties['user.dir']+'/src/test/resources/ExpectedOutput.json' And def exp_payload = karate.properties['user.dir']+'/src/test/resources/ExpectedOutput.json'
And print 'paht = '+exp_payload And print 'paht = '+exp_payload
And def exp = read('file:'+exp_payload) And def exp = read('file:'+exp_payload)
And print exp And print exp
And match response == exp And match response == exp
Scenario: Demo Put Call 1 Scenario: Demo Put Call 1
Given path '/users/2' Given path '/users/2'
And request req_payload And request req_payload
When method PUT When method PUT
And print response And print response
Then status 200 Then status 200
Scenario: Demo Patch Call 2 Scenario: Demo Patch Call 2
Given path '/users/2' Given path '/users/2'
And request req_payload And request req_payload
When method PATCH When method PATCH
And print response And print response
Then status 200 Then status 200
Scenario: Demo Delete Call 1 Scenario: Demo Delete Call 1
Given path '/users/2' Given path '/users/2'
When method DELETE When method DELETE
And print response And print response
Then status 204 Then status 204
Scenario: Demo Karate Config file Scenario: Demo Karate Config file
......
Feature: Test Feature
Background:
* url baseURL
* header Accept = 'application/json'
* def req_payload = read('request.json')
@nazoor
Scenario: Demo Karate Config file
Given print name
When print baseURL
When print baseURL
\ No newline at end of file
import com.intuit.karate.KarateOptions;
import com.intuit.karate.junit4.Karate; import com.intuit.karate.junit4.Karate;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@RunWith(Karate.class) @RunWith(Karate.class)
public class TestRunner { public class TestRunner{
@BeforeClass @BeforeClass
......
...@@ -13,14 +13,27 @@ function fn(){ ...@@ -13,14 +13,27 @@ function fn(){
karate.configure('connectTimeout', 5000); karate.configure('connectTimeout', 5000);
karate.configure('readTimeout', 5000); karate.configure('readTimeout', 5000);
switch(env)
if(env=='QA1') {
{ case 'QA1':
config.baseURL = 'https://reqres.in/api/'; config.baseURL = 'https://reqres.in/api/';
} break;
else if(env == 'QA2'){ case 'QA2':
config.baseURL = 'https://reqres.in/api/';
} config.baseURL = 'https://reqres.in/api/';
break;
default :
config.baseURL = 'https://reqres.in/api/';
break;
}
// if(env=='QA1')
// {
// config.baseURL = 'https://reqres.in/api/';
// }
// else if(env == 'QA2'){
// config.baseURL = 'https://reqres.in/api/';
// }
karate.log('Base URL = ',config.baseURL) karate.log('Base URL = ',config.baseURL)
......
allure.results.directory=allure-results
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment