SlideShare a Scribd company logo
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

More Related Content

What's hot

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
Sqreen
 
Gradle basics
Gradle basicsGradle basics
Gradle basics
Pedro Borrayo
 
GC Tuning & Troubleshooting Crash Course
GC Tuning & Troubleshooting Crash CourseGC Tuning & Troubleshooting Crash Course
GC Tuning & Troubleshooting Crash Course
Tier1 app
 
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldJavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
Robert Nyman
 
Drools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationDrools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentation
Mark Proctor
 
Mongo db updatedocumentusecases
Mongo db updatedocumentusecasesMongo db updatedocumentusecases
Mongo db updatedocumentusecases
zarigatongy
 
Upgrading Grails 1.x to 2
Upgrading Grails 1.x to 2Upgrading Grails 1.x to 2
Upgrading Grails 1.x to 2
wbucksoft
 
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.js
Future 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 Lazy
Johnathan 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
 
Bootstrap
BootstrapBootstrap
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를 통한 엣지 컴퓨팅 서비스
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 Ming
Rick Copeland
 
Operational transformation
Operational transformationOperational transformation
Operational transformationMatteo Collina
 
JavaScript Abstraction
JavaScript AbstractionJavaScript Abstraction
JavaScript Abstraction
☆ Milan Adamovsky ☆
 

What's hot (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 to Taller evento TestingUY 2017 - API Testing utilizando Chakram

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
Andy McKay
 
HRServicesPOX.classpathHRServicesPOX.project HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project  HRSer.docxHRServicesPOX.classpathHRServicesPOX.project  HRSer.docx
HRServicesPOX.classpathHRServicesPOX.project HRSer.docx
adampcarr67227
 
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
Matt 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 2017
Matt 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 Kotlin
Dmitriy 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 Ces
Leonardo Fernandes
 
Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019Get Hip with JHipster - GIDS 2019
Get Hip with JHipster - GIDS 2019
Matt 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 2020
Matt 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 2019
Matt 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
 
Old WP REST API, New Tricks
Old WP REST API, New TricksOld WP REST API, New Tricks
Old WP REST API, New Tricks
WordPress Community Montreal
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
Neil 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 Services
Rainer 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
 
Ams adapters
Ams adaptersAms adapters
Ams adapters
Bruno Alló Bacarini
 
Node.js and Parse
Node.js and ParseNode.js and Parse
Node.js and Parse
Nicholas McClay
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
Vivian S. Zhang
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
Forziatech
 
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
Matt Raible
 

Similar to Taller evento TestingUY 2017 - API Testing utilizando Chakram (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
 

More from 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 opcional
TestingUy
 
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 testing
TestingUy
 
TestingPy meetup - Invitación TestingUy 2020
TestingPy meetup - Invitación TestingUy 2020TestingPy meetup - Invitación TestingUy 2020
TestingPy meetup - Invitación TestingUy 2020
TestingUy
 
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
TestingUy
 
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
TestingUy
 
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 JMeter
TestingUy
 
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
TestingUy
 
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 Pact
TestingUy
 
Charla TestingUy 2019 - Testing de chatbots
Charla TestingUy 2019 - Testing de chatbotsCharla TestingUy 2019 - Testing de chatbots
Charla TestingUy 2019 - Testing de chatbots
TestingUy
 
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
TestingUy
 
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
 

More from 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...
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 

Taller evento TestingUY 2017 - API Testing utilizando Chakram

  • 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