SlideShare una empresa de Scribd logo
1 de 14
Eng. Walter Lijo
lijowalter@gmail.com
API testing using Chakram.
15 y 16 de mayo, 2017
www.testinguy.org
#testinguy |@testinguy
What we are going to use ...
o Chakram
o http://dareid.github.io/chakram/
o Mocha
o https://mochajs.org/
o Chai
o http://chaijs.com/
o Mochawesome
o https://github.com/adamgruber/mochawesome
What is Chakram?
o Chakram is a REST API testing framework offering a BDD testing style and fully
exploiting promises
o This framework allows us to:
o Make HTTP Assertions
o Exploit Promises
o Use BDD + Hooks
o Extensibility
o Community support
What do we need?
o Project for MeetUp
o https://github.com/woolter/RestAPITesting
o ~/Documents $ git clone https://github.com/woolter/RestAPITesting.git
o ~/Documents $ cd RestAPITesting
o ~/Documents/RestAPITesting $ git checkout exercise
o Spring boot rest api example
o http://websystique.com/spring-boot/spring-boot-rest-api-example/
Step 1 - Getting Started
With the next few commands we can set up or project from scratch.
~/projectFolder $ npm install -g mocha
~/projectFolder $ npm init
~/projectFolder $ npm install --save-dev chakram
~/projectFolder $ npm install --save-dev mochawesome
~/projectFolder $ mkdir data
~/projectFolder $ mkdir test
To start our Spring boot rest api example
~/RestAPITesting/SpringBootRestApiExample $ mvn spring-boot:run
Step 2 - Get
o Create endpoint.json on data folder
o Create ddt.json on data folder
o Create 1_Get.js on test folder with this:
o Create variables for validation
https://jsonschema.net/#/editor
o Create function for all users and user by id
{
"user":"SpringBootRestApi/api/user/",
"userById":"SpringBootRestApi/api/user/{id}"
}
{
"environment":
{
"protocol":"http://",
"hostname":"localhost",
"port":":8080/"
}
}
let chakram = require('chakram');
let expect = chakram.expect;
endPoint = require('../data/endPoint.json');
ddt = require('../data/ddt.json');
"http://user:password@site
-----------------------------------------------------------
"login":"/j_spring_security_check?j_usernam
e={userName}&j_password={password}",
return chakram.get(request, {jar: cookie})
Step 2 - Get (continue)
o Basic test: get all users
o New test: get user by id
o Execute test
~/projectFolder/test $ mocha 1_Get.js
describe("Get", function () {
it("All User", function () {
return chakram.get(allUser())
.then(function (response) {
expect(response).to.have.schema(schemaGetAll);
expect(response.response.statusCode).to.equal(200);
})
});
});
it("User by ID", function () {
let userID = userById(1);
return chakram.get(userID)
.then(function (response) {
expect(response).to.have.schema(schemaGetById);
})
});
Step 3 - Post
o Create 2_Post.js on test folder with this:
o Add schema to create user
o Add variable for validation
o Add function for
o Create user
o Get user by Id
o Create test case to create user with existing user name
let chakram = require('chakram');
let expect = chakram.expect;
endPoint = require('../data/endPoint.json');
ddt = require('../data/ddt.json');
let bodyCreateUser = {
name: "",
age: "",
salary: ""
};
o Add data to ddt.json
"userData":{
"name":"yourName",
"age":35,
"salary":123456
}
it("Create a User with an existing name", function () {
bodyCreateUser.name = ddt.userData.name;
bodyCreateUser.age = ddt.userData.age;
bodyCreateUser.salary = ddt.userData.salary;
return chakram.post(createUser(), bodyCreateUser)
.then(function (response) {
expect(response.response.statusCode).to.equal(409);
expect(response.response.body.errorMessage).to.equal("Unable to
create. A User with name "+ddt.userData.name+" already" +
" exist.");
})
});
o Execute test
~/projectFolder/test $ mocha 2_Post.js
Step 4 - Put
o Create 3_Put.js on test folder with this:
o Add schema for update user
o Add function for
o Get user by Id
o Create test case to update age
let chakram = require('chakram');
let expect = chakram.expect;
endPoint = require('../data/endPoint.json');
ddt = require('../data/ddt.json');
let bodyCreteUser = {
name: "",
age: "",
salary: ""
};
it("Update Age", function () {
bodyCreateUser.name = userIdInformation.name;
bodyCreateUser.age = ddt.userData.ageUpdate;
bodyCreateUser.salary = userIdInformation.salary;
return chakram.put(userById(userIdToSearch),bodyCreateUser)
.then(function (response) {
expect(response.body.id).to.equal(userIdToSearch);
expect(response.body.name).to.equal(userIdInformation.name);
expect(response.body.age).to.equal(ddt.userData.ageUpdate);
expect(response.body.salary).to.equal(userIdInformation.salary);
})
});
o Execute test
~/projectFolder/test $ mocha 3_Put.js
Step 5 - Delete
o Create 4_Delete.js on test folder with:
o Required deferences
o Function to:
o Delete all user
o Delete user by Id
o Test case:
o Delete by Id
o Delete all
let chakram = require('chakram');
let expect = chakram.expect;
endPoint = require('../data/endPoint.json');
ddt = require('../data/ddt.json');ringBootRestApi/api/user/{id}"
function deleteAllUser() {
let users = ddt.environment.protocol + ddt.environment.hostname +
ddt.environment.port + endPoint.user;
return users;
}
function deleteUserById(id) {
let usersID = ddt.environment.protocol + ddt.environment.hostname +
ddt.environment.port + endPoint.userById;
usersID = usersID.replace("{id}", id);
return usersID;
}
describe("Delete", function () {
it("Delete by Id", function () {
let userID = deleteUserById(ddt.userData.deleteId);
return chakram.delete(userID)
.then(function (response) {
expect(response.response.statusCode).to.equal(204);
return chakram.get(userID)
.then(function (response) {
expect(response.response.body.errorMessage).to.equal("User
with id " + ddt.userData.deleteId + " not found");
})
})
});
});
it("All User", function () {
return chakram.delete(deleteAllUser())
.then(function (response) {
expect(response.response.statusCode).to.equal(204);
return chakram.get(deleteAllUser())
.then(function (response) {
expect(response.response.statusCode).to.equal(204);
console.log(response);
})
})
});
o Execute test
~/projectFolder/test $ mocha 4_Delete.js
Step 6 - Execute all test case
o Execute test
~/projectFolder $ mocha --recursive testCaseFolder/ --reporter mochawesome
Useful
o JavaScript function:
JSON.stringify();
o Schema validation:
http://json-schema.org/latest/json-schema-validation.html
o Json schema creator
https://jsonschema.net/#/editor
o MeetUp
https://www.meetup.com/es/TestingAR/
o Slack
https://wt-iesmite-gmail_com-0.run.webtask.io/testingar-signup
o Twitter
@TestingARMeetup
Ing. Walter Lijo
lijowalter@gmail.com
¿PREGUNTAS?
¡MUCHAS GRACIAS!
15 y 16 de mayo, 2017
www.testinguy.org
#testinguy |@testinguy

Más contenido relacionado

La actualidad más candente

NoSQL Injections in Node.js - The case of MongoDB
NoSQL Injections in Node.js - The case of MongoDBNoSQL Injections in Node.js - The case of MongoDB
NoSQL Injections in Node.js - The case of MongoDBSqreen
 
GC Tuning & Troubleshooting Crash Course
GC Tuning & Troubleshooting Crash CourseGC Tuning & Troubleshooting Crash Course
GC Tuning & Troubleshooting Crash CourseTier1 app
 
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldJavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldRobert Nyman
 
Drools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationDrools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationMark Proctor
 
Mongo db updatedocumentusecases
Mongo db updatedocumentusecasesMongo db updatedocumentusecases
Mongo db updatedocumentusecaseszarigatongy
 
Upgrading Grails 1.x to 2
Upgrading Grails 1.x to 2Upgrading Grails 1.x to 2
Upgrading Grails 1.x to 2wbucksoft
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 SpringKiyotaka Oku
 
Creating Applications with WebGL and Three.js
Creating Applications with WebGL and Three.jsCreating Applications with WebGL and Three.js
Creating Applications with WebGL and Three.jsFuture Insights
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web PerformanceAdam Lu
 
mDevCamp - The Best from Google IO
mDevCamp - The Best from Google IOmDevCamp - The Best from Google IO
mDevCamp - The Best from Google IOondraz
 
Lazy Loading Because I'm Lazy
Lazy Loading Because I'm LazyLazy Loading Because I'm Lazy
Lazy Loading Because I'm LazyJohnathan Leppert
 
Qtp script to connect access database
Qtp script to connect access databaseQtp script to connect access database
Qtp script to connect access databaseRamu Palanki
 
MongoDB Indexing Constraints and Creative Schemas
MongoDB Indexing Constraints and Creative SchemasMongoDB Indexing Constraints and Creative Schemas
MongoDB Indexing Constraints and Creative SchemasMongoDB
 
AWS 9월 웨비나 | AWS Lambda@Edge를 통한 엣지 컴퓨팅 서비스
AWS 9월 웨비나 | AWS Lambda@Edge를 통한 엣지 컴퓨팅 서비스 AWS 9월 웨비나 | AWS Lambda@Edge를 통한 엣지 컴퓨팅 서비스
AWS 9월 웨비나 | AWS Lambda@Edge를 통한 엣지 컴퓨팅 서비스 Amazon Web Services Korea
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRick Copeland
 
Operational transformation
Operational transformationOperational transformation
Operational transformationMatteo Collina
 

La actualidad más candente (20)

NoSQL Injections in Node.js - The case of MongoDB
NoSQL Injections in Node.js - The case of MongoDBNoSQL Injections in Node.js - The case of MongoDB
NoSQL Injections in Node.js - The case of MongoDB
 
Gradle basics
Gradle basicsGradle basics
Gradle basics
 
GC Tuning & Troubleshooting Crash Course
GC Tuning & Troubleshooting Crash CourseGC Tuning & Troubleshooting Crash Course
GC Tuning & Troubleshooting Crash Course
 
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldJavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
 
Drools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationDrools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentation
 
Mongo db updatedocumentusecases
Mongo db updatedocumentusecasesMongo db updatedocumentusecases
Mongo db updatedocumentusecases
 
Upgrading Grails 1.x to 2
Upgrading Grails 1.x to 2Upgrading Grails 1.x to 2
Upgrading Grails 1.x to 2
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
Creating Applications with WebGL and Three.js
Creating Applications with WebGL and Three.jsCreating Applications with WebGL and Three.js
Creating Applications with WebGL and Three.js
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web Performance
 
mDevCamp - The Best from Google IO
mDevCamp - The Best from Google IOmDevCamp - The Best from Google IO
mDevCamp - The Best from Google IO
 
Lazy Loading Because I'm Lazy
Lazy Loading Because I'm LazyLazy Loading Because I'm Lazy
Lazy Loading Because I'm Lazy
 
Qtp script to connect access database
Qtp script to connect access databaseQtp script to connect access database
Qtp script to connect access database
 
MongoDB Indexing Constraints and Creative Schemas
MongoDB Indexing Constraints and Creative SchemasMongoDB Indexing Constraints and Creative Schemas
MongoDB Indexing Constraints and Creative Schemas
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
HTML,CSS Next
HTML,CSS NextHTML,CSS Next
HTML,CSS Next
 
AWS 9월 웨비나 | AWS Lambda@Edge를 통한 엣지 컴퓨팅 서비스
AWS 9월 웨비나 | AWS Lambda@Edge를 통한 엣지 컴퓨팅 서비스 AWS 9월 웨비나 | AWS Lambda@Edge를 통한 엣지 컴퓨팅 서비스
AWS 9월 웨비나 | AWS Lambda@Edge를 통한 엣지 컴퓨팅 서비스
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
 
Operational transformation
Operational transformationOperational transformation
Operational transformation
 
JavaScript Abstraction
JavaScript AbstractionJavaScript Abstraction
JavaScript Abstraction
 

Similar a API Testing Using Chakram Framework

Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineAndy McKay
 
HRServicesPOX.classpathHRServicesPOX.project HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project  HRSer.docxHRServicesPOX.classpathHRServicesPOX.project  HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project HRSer.docxadampcarr67227
 
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019Matt Raible
 
Front End Development for Back End Developers - vJUG24 2017
Front End Development for Back End Developers - vJUG24 2017Front End Development for Back End Developers - vJUG24 2017
Front End Development for Back End Developers - vJUG24 2017Matt Raible
 
Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDmitriy Sobko
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesLeonardo Fernandes
 
Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019Matt Raible
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020Matt Raible
 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019Matt Raible
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiRan Mizrahi
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsNeil Crookes
 
AngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesAngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesRainer Stropek
 
10 ways to make your code rock
10 ways to make your code rock10 ways to make your code rock
10 ways to make your code rockmartincronje
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptForziatech
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019Matt Raible
 

Similar a API Testing Using Chakram Framework (20)

Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
HRServicesPOX.classpathHRServicesPOX.project HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project  HRSer.docxHRServicesPOX.classpathHRServicesPOX.project  HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project HRSer.docx
 
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
 
Front End Development for Back End Developers - vJUG24 2017
Front End Development for Back End Developers - vJUG24 2017Front End Development for Back End Developers - vJUG24 2017
Front End Development for Back End Developers - vJUG24 2017
 
huhu
huhuhuhu
huhu
 
Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in Kotlin
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
 
Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
Old WP REST API, New Tricks
Old WP REST API, New TricksOld WP REST API, New Tricks
Old WP REST API, New Tricks
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 
AngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesAngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile Services
 
10 ways to make your code rock
10 ways to make your code rock10 ways to make your code rock
10 ways to make your code rock
 
Ams adapters
Ams adaptersAms adapters
Ams adapters
 
Node.js and Parse
Node.js and ParseNode.js and Parse
Node.js and Parse
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019
 

Más de TestingUy

Webinar TestingUy - Cuando el testing no es opcional
Webinar TestingUy - Cuando el testing no es opcionalWebinar TestingUy - Cuando el testing no es opcional
Webinar TestingUy - Cuando el testing no es opcionalTestingUy
 
Webinar TestingUy - Usando Principios del Testing de Software en Tiempos de C...
Webinar TestingUy - Usando Principios del Testing de Software en Tiempos de C...Webinar TestingUy - Usando Principios del Testing de Software en Tiempos de C...
Webinar TestingUy - Usando Principios del Testing de Software en Tiempos de C...TestingUy
 
Webinar TestingUy - Sesgos cognitivos en las pruebas. El lado más humano de...
Webinar TestingUy -   Sesgos cognitivos en las pruebas. El lado más humano de...Webinar TestingUy -   Sesgos cognitivos en las pruebas. El lado más humano de...
Webinar TestingUy - Sesgos cognitivos en las pruebas. El lado más humano de...TestingUy
 
Webinar TestingUy - Thinking outside the box: Cognitive bias and testing
Webinar TestingUy - Thinking outside the box: Cognitive bias and testingWebinar TestingUy - Thinking outside the box: Cognitive bias and testing
Webinar TestingUy - Thinking outside the box: Cognitive bias and testingTestingUy
 
TestingPy meetup - Invitación TestingUy 2020
TestingPy meetup - Invitación TestingUy 2020TestingPy meetup - Invitación TestingUy 2020
TestingPy meetup - Invitación TestingUy 2020TestingUy
 
Meetup TestingUy 2019 - Plataforma de integración y testing continuo
Meetup TestingUy 2019 - Plataforma de integración y testing continuoMeetup TestingUy 2019 - Plataforma de integración y testing continuo
Meetup TestingUy 2019 - Plataforma de integración y testing continuoTestingUy
 
Meetup TestingUy 2019 - May the automation be with you
Meetup TestingUy 2019 - May the automation be with youMeetup TestingUy 2019 - May the automation be with you
Meetup TestingUy 2019 - May the automation be with youTestingUy
 
Meetup TestingUy 2019 - De árboles, de bosques y de selvas ¿qué visión tengo ...
Meetup TestingUy 2019 - De árboles, de bosques y de selvas ¿qué visión tengo ...Meetup TestingUy 2019 - De árboles, de bosques y de selvas ¿qué visión tengo ...
Meetup TestingUy 2019 - De árboles, de bosques y de selvas ¿qué visión tengo ...TestingUy
 
Meetup TestingUy 2019 - En clave de protocolo con apache JMeter
Meetup TestingUy 2019 - En clave de protocolo con apache JMeterMeetup TestingUy 2019 - En clave de protocolo con apache JMeter
Meetup TestingUy 2019 - En clave de protocolo con apache JMeterTestingUy
 
Meetup TestingUy 2019 - Si Tony Stark fuera Tester
Meetup TestingUy 2019 - Si Tony Stark fuera TesterMeetup TestingUy 2019 - Si Tony Stark fuera Tester
Meetup TestingUy 2019 - Si Tony Stark fuera TesterTestingUy
 
Meetup TestingUy 2019 - ¿Test cases? ¿Son siempre necesarios?
Meetup TestingUy 2019 - ¿Test cases? ¿Son siempre necesarios?Meetup TestingUy 2019 - ¿Test cases? ¿Son siempre necesarios?
Meetup TestingUy 2019 - ¿Test cases? ¿Son siempre necesarios?TestingUy
 
Charla TestingUy 2019 - ¿Podemos hacer que la seguridad sea usable?
Charla TestingUy 2019 - ¿Podemos hacer que la seguridad sea usable?Charla TestingUy 2019 - ¿Podemos hacer que la seguridad sea usable?
Charla TestingUy 2019 - ¿Podemos hacer que la seguridad sea usable?TestingUy
 
Charla TestingUy 2019 - Testers as Test Consultants: How to learn the skills?
Charla TestingUy 2019 - Testers as Test Consultants: How to learn the skills?Charla TestingUy 2019 - Testers as Test Consultants: How to learn the skills?
Charla TestingUy 2019 - Testers as Test Consultants: How to learn the skills?TestingUy
 
Charla TestingUy 2019 - Ready Tester One? Go!
Charla TestingUy 2019 - Ready Tester One? Go!Charla TestingUy 2019 - Ready Tester One? Go!
Charla TestingUy 2019 - Ready Tester One? Go!TestingUy
 
Charla TestingUy 2019 - Patterns Para Enseñar Testing a Personas que No Desar...
Charla TestingUy 2019 - Patterns Para Enseñar Testing a Personas que No Desar...Charla TestingUy 2019 - Patterns Para Enseñar Testing a Personas que No Desar...
Charla TestingUy 2019 - Patterns Para Enseñar Testing a Personas que No Desar...TestingUy
 
Charla TestingUy 2019 - Contract Testing con Pact
Charla TestingUy 2019 - Contract Testing con PactCharla TestingUy 2019 - Contract Testing con Pact
Charla TestingUy 2019 - Contract Testing con PactTestingUy
 
Charla TestingUy 2019 - Testing de chatbots
Charla TestingUy 2019 - Testing de chatbotsCharla TestingUy 2019 - Testing de chatbots
Charla TestingUy 2019 - Testing de chatbotsTestingUy
 
Charla TestingUy 2019 - Cypress.io - Automatización al siguiente nivel
Charla TestingUy 2019 - Cypress.io - Automatización al siguiente nivelCharla TestingUy 2019 - Cypress.io - Automatización al siguiente nivel
Charla TestingUy 2019 - Cypress.io - Automatización al siguiente nivelTestingUy
 
Charla testingUy 2019 - ¿De dónde venimos y qué se nos viene? - Evolución de ...
Charla testingUy 2019 - ¿De dónde venimos y qué se nos viene? - Evolución de ...Charla testingUy 2019 - ¿De dónde venimos y qué se nos viene? - Evolución de ...
Charla testingUy 2019 - ¿De dónde venimos y qué se nos viene? - Evolución de ...TestingUy
 
Charla TestingUy 2019 - Pruebas de rendimiento, experiencias en la plataforma...
Charla TestingUy 2019 - Pruebas de rendimiento, experiencias en la plataforma...Charla TestingUy 2019 - Pruebas de rendimiento, experiencias en la plataforma...
Charla TestingUy 2019 - Pruebas de rendimiento, experiencias en la plataforma...TestingUy
 

Más de TestingUy (20)

Webinar TestingUy - Cuando el testing no es opcional
Webinar TestingUy - Cuando el testing no es opcionalWebinar TestingUy - Cuando el testing no es opcional
Webinar TestingUy - Cuando el testing no es opcional
 
Webinar TestingUy - Usando Principios del Testing de Software en Tiempos de C...
Webinar TestingUy - Usando Principios del Testing de Software en Tiempos de C...Webinar TestingUy - Usando Principios del Testing de Software en Tiempos de C...
Webinar TestingUy - Usando Principios del Testing de Software en Tiempos de C...
 
Webinar TestingUy - Sesgos cognitivos en las pruebas. El lado más humano de...
Webinar TestingUy -   Sesgos cognitivos en las pruebas. El lado más humano de...Webinar TestingUy -   Sesgos cognitivos en las pruebas. El lado más humano de...
Webinar TestingUy - Sesgos cognitivos en las pruebas. El lado más humano de...
 
Webinar TestingUy - Thinking outside the box: Cognitive bias and testing
Webinar TestingUy - Thinking outside the box: Cognitive bias and testingWebinar TestingUy - Thinking outside the box: Cognitive bias and testing
Webinar TestingUy - Thinking outside the box: Cognitive bias and testing
 
TestingPy meetup - Invitación TestingUy 2020
TestingPy meetup - Invitación TestingUy 2020TestingPy meetup - Invitación TestingUy 2020
TestingPy meetup - Invitación TestingUy 2020
 
Meetup TestingUy 2019 - Plataforma de integración y testing continuo
Meetup TestingUy 2019 - Plataforma de integración y testing continuoMeetup TestingUy 2019 - Plataforma de integración y testing continuo
Meetup TestingUy 2019 - Plataforma de integración y testing continuo
 
Meetup TestingUy 2019 - May the automation be with you
Meetup TestingUy 2019 - May the automation be with youMeetup TestingUy 2019 - May the automation be with you
Meetup TestingUy 2019 - May the automation be with you
 
Meetup TestingUy 2019 - De árboles, de bosques y de selvas ¿qué visión tengo ...
Meetup TestingUy 2019 - De árboles, de bosques y de selvas ¿qué visión tengo ...Meetup TestingUy 2019 - De árboles, de bosques y de selvas ¿qué visión tengo ...
Meetup TestingUy 2019 - De árboles, de bosques y de selvas ¿qué visión tengo ...
 
Meetup TestingUy 2019 - En clave de protocolo con apache JMeter
Meetup TestingUy 2019 - En clave de protocolo con apache JMeterMeetup TestingUy 2019 - En clave de protocolo con apache JMeter
Meetup TestingUy 2019 - En clave de protocolo con apache JMeter
 
Meetup TestingUy 2019 - Si Tony Stark fuera Tester
Meetup TestingUy 2019 - Si Tony Stark fuera TesterMeetup TestingUy 2019 - Si Tony Stark fuera Tester
Meetup TestingUy 2019 - Si Tony Stark fuera Tester
 
Meetup TestingUy 2019 - ¿Test cases? ¿Son siempre necesarios?
Meetup TestingUy 2019 - ¿Test cases? ¿Son siempre necesarios?Meetup TestingUy 2019 - ¿Test cases? ¿Son siempre necesarios?
Meetup TestingUy 2019 - ¿Test cases? ¿Son siempre necesarios?
 
Charla TestingUy 2019 - ¿Podemos hacer que la seguridad sea usable?
Charla TestingUy 2019 - ¿Podemos hacer que la seguridad sea usable?Charla TestingUy 2019 - ¿Podemos hacer que la seguridad sea usable?
Charla TestingUy 2019 - ¿Podemos hacer que la seguridad sea usable?
 
Charla TestingUy 2019 - Testers as Test Consultants: How to learn the skills?
Charla TestingUy 2019 - Testers as Test Consultants: How to learn the skills?Charla TestingUy 2019 - Testers as Test Consultants: How to learn the skills?
Charla TestingUy 2019 - Testers as Test Consultants: How to learn the skills?
 
Charla TestingUy 2019 - Ready Tester One? Go!
Charla TestingUy 2019 - Ready Tester One? Go!Charla TestingUy 2019 - Ready Tester One? Go!
Charla TestingUy 2019 - Ready Tester One? Go!
 
Charla TestingUy 2019 - Patterns Para Enseñar Testing a Personas que No Desar...
Charla TestingUy 2019 - Patterns Para Enseñar Testing a Personas que No Desar...Charla TestingUy 2019 - Patterns Para Enseñar Testing a Personas que No Desar...
Charla TestingUy 2019 - Patterns Para Enseñar Testing a Personas que No Desar...
 
Charla TestingUy 2019 - Contract Testing con Pact
Charla TestingUy 2019 - Contract Testing con PactCharla TestingUy 2019 - Contract Testing con Pact
Charla TestingUy 2019 - Contract Testing con Pact
 
Charla TestingUy 2019 - Testing de chatbots
Charla TestingUy 2019 - Testing de chatbotsCharla TestingUy 2019 - Testing de chatbots
Charla TestingUy 2019 - Testing de chatbots
 
Charla TestingUy 2019 - Cypress.io - Automatización al siguiente nivel
Charla TestingUy 2019 - Cypress.io - Automatización al siguiente nivelCharla TestingUy 2019 - Cypress.io - Automatización al siguiente nivel
Charla TestingUy 2019 - Cypress.io - Automatización al siguiente nivel
 
Charla testingUy 2019 - ¿De dónde venimos y qué se nos viene? - Evolución de ...
Charla testingUy 2019 - ¿De dónde venimos y qué se nos viene? - Evolución de ...Charla testingUy 2019 - ¿De dónde venimos y qué se nos viene? - Evolución de ...
Charla testingUy 2019 - ¿De dónde venimos y qué se nos viene? - Evolución de ...
 
Charla TestingUy 2019 - Pruebas de rendimiento, experiencias en la plataforma...
Charla TestingUy 2019 - Pruebas de rendimiento, experiencias en la plataforma...Charla TestingUy 2019 - Pruebas de rendimiento, experiencias en la plataforma...
Charla TestingUy 2019 - Pruebas de rendimiento, experiencias en la plataforma...
 

Último

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Último (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

API Testing Using Chakram Framework

  • 1. Eng. Walter Lijo lijowalter@gmail.com API testing using Chakram. 15 y 16 de mayo, 2017 www.testinguy.org #testinguy |@testinguy
  • 2. What we are going to use ... o Chakram o http://dareid.github.io/chakram/ o Mocha o https://mochajs.org/ o Chai o http://chaijs.com/ o Mochawesome o https://github.com/adamgruber/mochawesome
  • 3. What is Chakram? o Chakram is a REST API testing framework offering a BDD testing style and fully exploiting promises o This framework allows us to: o Make HTTP Assertions o Exploit Promises o Use BDD + Hooks o Extensibility o Community support
  • 4. What do we need? o Project for MeetUp o https://github.com/woolter/RestAPITesting o ~/Documents $ git clone https://github.com/woolter/RestAPITesting.git o ~/Documents $ cd RestAPITesting o ~/Documents/RestAPITesting $ git checkout exercise o Spring boot rest api example o http://websystique.com/spring-boot/spring-boot-rest-api-example/
  • 5. Step 1 - Getting Started With the next few commands we can set up or project from scratch. ~/projectFolder $ npm install -g mocha ~/projectFolder $ npm init ~/projectFolder $ npm install --save-dev chakram ~/projectFolder $ npm install --save-dev mochawesome ~/projectFolder $ mkdir data ~/projectFolder $ mkdir test To start our Spring boot rest api example ~/RestAPITesting/SpringBootRestApiExample $ mvn spring-boot:run
  • 6. Step 2 - Get o Create endpoint.json on data folder o Create ddt.json on data folder o Create 1_Get.js on test folder with this: o Create variables for validation https://jsonschema.net/#/editor o Create function for all users and user by id { "user":"SpringBootRestApi/api/user/", "userById":"SpringBootRestApi/api/user/{id}" } { "environment": { "protocol":"http://", "hostname":"localhost", "port":":8080/" } } let chakram = require('chakram'); let expect = chakram.expect; endPoint = require('../data/endPoint.json'); ddt = require('../data/ddt.json'); "http://user:password@site ----------------------------------------------------------- "login":"/j_spring_security_check?j_usernam e={userName}&j_password={password}", return chakram.get(request, {jar: cookie})
  • 7. Step 2 - Get (continue) o Basic test: get all users o New test: get user by id o Execute test ~/projectFolder/test $ mocha 1_Get.js describe("Get", function () { it("All User", function () { return chakram.get(allUser()) .then(function (response) { expect(response).to.have.schema(schemaGetAll); expect(response.response.statusCode).to.equal(200); }) }); }); it("User by ID", function () { let userID = userById(1); return chakram.get(userID) .then(function (response) { expect(response).to.have.schema(schemaGetById); }) });
  • 8. Step 3 - Post o Create 2_Post.js on test folder with this: o Add schema to create user o Add variable for validation o Add function for o Create user o Get user by Id o Create test case to create user with existing user name let chakram = require('chakram'); let expect = chakram.expect; endPoint = require('../data/endPoint.json'); ddt = require('../data/ddt.json'); let bodyCreateUser = { name: "", age: "", salary: "" }; o Add data to ddt.json "userData":{ "name":"yourName", "age":35, "salary":123456 } it("Create a User with an existing name", function () { bodyCreateUser.name = ddt.userData.name; bodyCreateUser.age = ddt.userData.age; bodyCreateUser.salary = ddt.userData.salary; return chakram.post(createUser(), bodyCreateUser) .then(function (response) { expect(response.response.statusCode).to.equal(409); expect(response.response.body.errorMessage).to.equal("Unable to create. A User with name "+ddt.userData.name+" already" + " exist."); }) }); o Execute test ~/projectFolder/test $ mocha 2_Post.js
  • 9. Step 4 - Put o Create 3_Put.js on test folder with this: o Add schema for update user o Add function for o Get user by Id o Create test case to update age let chakram = require('chakram'); let expect = chakram.expect; endPoint = require('../data/endPoint.json'); ddt = require('../data/ddt.json'); let bodyCreteUser = { name: "", age: "", salary: "" }; it("Update Age", function () { bodyCreateUser.name = userIdInformation.name; bodyCreateUser.age = ddt.userData.ageUpdate; bodyCreateUser.salary = userIdInformation.salary; return chakram.put(userById(userIdToSearch),bodyCreateUser) .then(function (response) { expect(response.body.id).to.equal(userIdToSearch); expect(response.body.name).to.equal(userIdInformation.name); expect(response.body.age).to.equal(ddt.userData.ageUpdate); expect(response.body.salary).to.equal(userIdInformation.salary); }) }); o Execute test ~/projectFolder/test $ mocha 3_Put.js
  • 10. Step 5 - Delete o Create 4_Delete.js on test folder with: o Required deferences o Function to: o Delete all user o Delete user by Id o Test case: o Delete by Id o Delete all let chakram = require('chakram'); let expect = chakram.expect; endPoint = require('../data/endPoint.json'); ddt = require('../data/ddt.json');ringBootRestApi/api/user/{id}" function deleteAllUser() { let users = ddt.environment.protocol + ddt.environment.hostname + ddt.environment.port + endPoint.user; return users; } function deleteUserById(id) { let usersID = ddt.environment.protocol + ddt.environment.hostname + ddt.environment.port + endPoint.userById; usersID = usersID.replace("{id}", id); return usersID; } describe("Delete", function () { it("Delete by Id", function () { let userID = deleteUserById(ddt.userData.deleteId); return chakram.delete(userID) .then(function (response) { expect(response.response.statusCode).to.equal(204); return chakram.get(userID) .then(function (response) { expect(response.response.body.errorMessage).to.equal("User with id " + ddt.userData.deleteId + " not found"); }) }) }); }); it("All User", function () { return chakram.delete(deleteAllUser()) .then(function (response) { expect(response.response.statusCode).to.equal(204); return chakram.get(deleteAllUser()) .then(function (response) { expect(response.response.statusCode).to.equal(204); console.log(response); }) }) }); o Execute test ~/projectFolder/test $ mocha 4_Delete.js
  • 11. Step 6 - Execute all test case o Execute test ~/projectFolder $ mocha --recursive testCaseFolder/ --reporter mochawesome
  • 12. Useful o JavaScript function: JSON.stringify(); o Schema validation: http://json-schema.org/latest/json-schema-validation.html o Json schema creator https://jsonschema.net/#/editor
  • 14. Ing. Walter Lijo lijowalter@gmail.com ¿PREGUNTAS? ¡MUCHAS GRACIAS! 15 y 16 de mayo, 2017 www.testinguy.org #testinguy |@testinguy