SlideShare une entreprise Scribd logo
1  sur  12
Télécharger pour lire hors ligne
Testování RESTful API v rámci continuous 
integration 
Bc. Martin Štekl 
steklmar@fit.cvut.cz 
12. ˇcervna 2014 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 1 / 12
Cíle práce 
Uspoˇrdádání znalostí o testování SW a o testování RESTful API 
Porovnání r °uzných nástroj °u na testování nebo popis RESTful API 
Vývoj ˇci vylepšení nástroje pro testování RESTful API 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 2 / 12
Proˇc toto téma? 
Málo zmapované testování RESTful API 
Relativnˇe málo nástroj °u 
Rˇ ešení reálného problému s testováním RESTful API 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 3 / 12
Analytická ˇcást práce 
Testovací proces vˇcetnˇe metod, typ °u a úrovní test °u 
Návaznosti na testování RESTful API 
Porovnání nástroj °u na testování nebo popis RESTful API 
Osobní konzultace s vývojáˇri z Apiary 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 4 / 12
Scénáˇrové testování RESTful API 
Doposud pouze vlastním kódem 
Žádná vazba na dokumentaci nebo na tutorial 
Cucumber - základní nástroj pro implementaci scénáˇrového 
testování RESTful API 
API Blueprint - jazyk pro popis RESTful API 
Zvolena implementace v JavaScriptu (Coffee Scriptu) 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 5 / 12
Cucumber 
Syntaxe Gherkin pro zápis test °u 
Základní stavební bloky Feature, Background a Scenario 
Jednotlivé kroky testu, tzv. Step definitions 
I Given 
I When 
I Then 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 6 / 12
Definice vlastních step definitions 
Naˇctení API Blueprint souboru 
Nastavení endpointu 
Výbˇ er akce z API Blueprint souboru 
Nastavení a asertace HTTP hlaviˇcek 
Nastavení a asertace t ˇ ela zprávy 
Speciální nastavení a asertace hlaviˇcky Content-Type 
Asertace HTTP kódu odpovˇ edi 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 7 / 12
Ukázka vlastního scénáˇre 
Background: 
Given API Blueprint in file "test/fixtures/apiary.apib" 
And base url http://localhost:3333 
Scenario: Create a Machine 
When I do action Machines > Machines collection >  
Create a Machine 
And the request message header Accept is application/json 
And the request message body is JSON 
""" 
{ 
"type": "bulldozer", 
"name": "willy" 
} 
""" 
Then It should be Accepted 
And the response message header Content-Encoding is none 
And the response message body is JSON 
""" 
{ 
"message": "Accepted" 
} 
""" 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 8 / 12
Výstup spuštˇeného testu 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 9 / 12
Testování samotného nástoje 
První verze výraznˇe zrefaktorována 
Automatické testy na serveru Travis CI pˇres GitHub hooky 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 10 / 12
Závˇ er 
Uspoˇrádané myšlenky a znalosti o testování RESTful API 
Základní verze nástroje pro scénáˇrové testování RESTful API 
Cíle práce byly naplnˇeny s drobnou odchylkou 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 11 / 12
Dˇ ekuji za pozornost 
Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 12 / 12

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Testování RESTful API v rámci continuous integration

  • 1. Testování RESTful API v rámci continuous integration Bc. Martin Štekl steklmar@fit.cvut.cz 12. ˇcervna 2014 Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 1 / 12
  • 2. Cíle práce Uspoˇrdádání znalostí o testování SW a o testování RESTful API Porovnání r °uzných nástroj °u na testování nebo popis RESTful API Vývoj ˇci vylepšení nástroje pro testování RESTful API Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 2 / 12
  • 3. Proˇc toto téma? Málo zmapované testování RESTful API Relativnˇe málo nástroj °u Rˇ ešení reálného problému s testováním RESTful API Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 3 / 12
  • 4. Analytická ˇcást práce Testovací proces vˇcetnˇe metod, typ °u a úrovní test °u Návaznosti na testování RESTful API Porovnání nástroj °u na testování nebo popis RESTful API Osobní konzultace s vývojáˇri z Apiary Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 4 / 12
  • 5. Scénáˇrové testování RESTful API Doposud pouze vlastním kódem Žádná vazba na dokumentaci nebo na tutorial Cucumber - základní nástroj pro implementaci scénáˇrového testování RESTful API API Blueprint - jazyk pro popis RESTful API Zvolena implementace v JavaScriptu (Coffee Scriptu) Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 5 / 12
  • 6. Cucumber Syntaxe Gherkin pro zápis test °u Základní stavební bloky Feature, Background a Scenario Jednotlivé kroky testu, tzv. Step definitions I Given I When I Then Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 6 / 12
  • 7. Definice vlastních step definitions Naˇctení API Blueprint souboru Nastavení endpointu Výbˇ er akce z API Blueprint souboru Nastavení a asertace HTTP hlaviˇcek Nastavení a asertace t ˇ ela zprávy Speciální nastavení a asertace hlaviˇcky Content-Type Asertace HTTP kódu odpovˇ edi Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 7 / 12
  • 8. Ukázka vlastního scénáˇre Background: Given API Blueprint in file "test/fixtures/apiary.apib" And base url http://localhost:3333 Scenario: Create a Machine When I do action Machines > Machines collection > Create a Machine And the request message header Accept is application/json And the request message body is JSON """ { "type": "bulldozer", "name": "willy" } """ Then It should be Accepted And the response message header Content-Encoding is none And the response message body is JSON """ { "message": "Accepted" } """ Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 8 / 12
  • 9. Výstup spuštˇeného testu Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 9 / 12
  • 10. Testování samotného nástoje První verze výraznˇe zrefaktorována Automatické testy na serveru Travis CI pˇres GitHub hooky Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 10 / 12
  • 11. Závˇ er Uspoˇrádané myšlenky a znalosti o testování RESTful API Základní verze nástroje pro scénáˇrové testování RESTful API Cíle práce byly naplnˇeny s drobnou odchylkou Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 11 / 12
  • 12. Dˇ ekuji za pozornost Bc. Martin Štekl (FIT Cˇ VUT) Testování RESTful API v rámci continuous integration 12. cˇervna 2014 12 / 12