SlideShare a Scribd company logo
REST API testing with 
SpecFlow 
Aistė Stikliūtė @ Visma Lietuva
Agenda 
Why SpecFlow REST API How to 
Details & tips Live demo 
Bonus: 
other uses of 
SpecFlow
Why SpecFlow 
• SoapUI? 
• Fitnesse? 
• Cucumber?
Why not… 
 SoapUI 
 Free version issues 
 Tests less easy to read 
 Thought there was no CI 
 Fitnesse 
 Works poorly with .NET 
 Wiki markup and tables interface is tiring 
 Cucumber 
 Yes – SpecFlow is Cucumber for .NET!
Continuous integration
BDD / Gherkin language 
GIVEN book with ISBN “1-84356-028-3” is in the system 
AND it’s available quantity is 9 
WHEN I add a book with ISBN “1-84356-028-3” 
THEN the book is successfully added to the list 
AND available qty. for book with ISBN “1-84356-028-3” is 10
The environment 
Same tool as 
for GUI tests 
(Visual Studio, 
C#) 
Same solution 
as GUI tests 
and even the 
whole system 
Convenient! 
Developers are 
integrated!
Rest API 
• What it is 
• Examples 
• Why test it
REST API 
 Web architectural style with a set of constraints 
 Web service APIs that adhere to the constraints - RESTful 
Frontend 
REST API 
Backend 
External 
system(s) 
External 
system(s)
Rest API: typically used HTTP methods 
Resource GET PUT POST DELETE 
Collection URI, 
such as 
http://example.com/res 
ources 
List 
collection's 
members 
Replace 
collection with 
another 
collection 
Create new 
entry in the 
collection 
Delete the 
entire 
collection 
Element URI, 
such as 
http://example.com/res 
ources/item17 
Retrieve 
the member 
of the 
collection 
Replace the 
member of the 
collection 
Not generally 
used 
Delete the 
member of the 
collection
Example 1 
Request 
 GET https://eshop.com/books/14765 
Response 
 Status: 200 OK 
{ 
"id": “14765", 
“title": “Game of Thrones", 
“author": “George R. R. Martin", 
“isbn": "1-84356-028-3", 
“availableQty": “4" 
}
Example 2 
Request 
 POST https://eshop.com/books 
{ 
“title": “501 Spanish Verbs", 
“author": “C. Kendris", 
“isbn": "1-84750-018-7", 
“availableQty": “10" 
} 
Response 
 Status: 200 OK 
{ 
“id": “78953“ 
}
Example 3 
Requests 
 DELETE 
https://eshop.com/book/84523 
 GET https://eshop.com/admin 
 PUT https://eshop.com/book/24552 
{ [some wrong data] } 
Responses 
 Status: 200 OK 
 Status: 401 Unauthorized 
 Status: 500 Internal Server Error
Why test Rest API? 
 If used by external applications: this is your UI! 
 As your system layer: 
 Can help find / isolate problems: 
Security 
Performance 
Robustness 
Functionality 
 May be more simple to test / automate than GUI tests
How to… 
…write tests
Step 1: know what your API should do 
 Documentation 
 Talk to developers 
 Browser’s Developer tools 
 REST client (e.g. Postman on Chrome)
Dev tools + REST client
Step 2: write your test scenarios 
 ListBooks.feature 
Scenario: There are no books in the system 
Given there are no books in the system 
When I retrieve list of all books 
Then I get empty list 
Scenario: There are less books than fit into 1 page 
Scenario: There are more books than fit into 1 page 
Scenario: Sort books 
Scenario: Search for a book
Step 3: generate scenario steps 
[Given(@”there are no books in the list”)] 
public void GivenThereAreNoBooksInTheList() 
{ 
ScenarioContext.Current.Pending(); 
}
Step 4: implement scenario steps 
 Here‘s where the Rest API calls go! 
 Plain C# can be used or libraries // I use RestSharp 
 Structure your project
Project structure 
 Features: all features, can have subfolders 
 Steps: bindings of features to actions 
 Actions: where things happen 
 Helpers: among others, RestHelper.cs 
 Model: classes matching our API data format 
 App.config: holds base URI
A quick look into code: Steps & Actions 
Steps 
Actions
A quick look into code: Model
A quick look into code: RestHelper.cs
Step 5: run tests
Step 6: add to Continuous Integration
Details & Tips
Hooks (event bindings) 
 Before / after test run  static 
 Before / after feature  static 
 Before / after scenario 
 Before / after scenario block (given / when / then) 
 Before / after step
Step scope and reusing 
 Steps are global! 
 Naming: “when I update it”  “when I update the book” 
 Scoped bindings: 
[Scope(Tag="my tag", Feature=“my feature", Scenario=“my scenario")] 
 Reusing step in other steps 
[Given(@"(.*) is logged in")] 
public void GivenIsLoggedIn(string name) { 
Given(string.Format("the user {0} exists", name)); 
Given(string.Format("I log in as {0}", name)); 
}
Table and multiline step arguments
Live Demo
Bonus 
Other uses of SpecFlow
Behaviour / 
Business Driven Development 
1. PO / QA writes scenarios 
2. Developer writes unit/integration tests 
3. Developer writes code until tests pass
Driving Selenium tests 
Scenario: Successful login 
Given I am at http://eshop.com/login 
When I login with user “John” and password “Password1” 
Then I am redirected to http://eshop.com/main 
Scenario: Successful login 
Given I am in login page 
When I login with correct credentials 
Then I am redirected to main page
SpecFlow & Selenium 
using scoped bindings 
[When(@"I perform a simple search on '(.*)'", Scope(Tag = “api"))] 
public void WhenIPerformASimpleSearchOn(string searchTerm) { 
var api = new CatalogApi(); 
actionResult = api.Search(searchTerm); 
} 
[When(@"I perform a simple search on '(.*)'"), Scope(Tag = "web")] 
public void PerformSimpleSearch(string title) { 
selenium.GoToThePage("Home"); selenium.Type("searchTerm", title); 
selenium.Click("searchButton"); 
}
Test case management / Test reporting 
 One functional test suite? 
 Manual 
 Automated API 
 Automated GUI 
 One report with test list that can be read by 
 POs and manual QAs 
 management 
 customer
Thank you! 
Time for questions 

More Related Content

What's hot

Rest assured
Rest assuredRest assured
Rest assured
Varun Deshpande
 
How to Automate API Testing
How to Automate API TestingHow to Automate API Testing
How to Automate API Testing
Bruno Pedro
 
Introduction to APIs & how to automate APIs testing with selenium web driver?
Introduction to APIs & how to automate APIs testing with selenium web driver?Introduction to APIs & how to automate APIs testing with selenium web driver?
Introduction to APIs & how to automate APIs testing with selenium web driver?
BugRaptors
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj Rollison
TEST Huddle
 
Inverting The Testing Pyramid
Inverting The Testing PyramidInverting The Testing Pyramid
Inverting The Testing Pyramid
Naresh Jain
 
Postman
PostmanPostman
API TESTING
API TESTINGAPI TESTING
API TESTING
Sijan Bhandari
 
Api testing
Api testingApi testing
Api testing
Keshav Kashyap
 
Automation Testing With Appium
Automation Testing With AppiumAutomation Testing With Appium
Automation Testing With Appium
Knoldus Inc.
 
B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testing
b4usolution .
 
Getting Started With Cypress
Getting Started With CypressGetting Started With Cypress
Getting Started With Cypress
Knoldus Inc.
 
RESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and JenkinsRESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and Jenkins
QASymphony
 
Postman Webinar: “Continuous Testing with Postman”
Postman Webinar: “Continuous Testing with Postman”Postman Webinar: “Continuous Testing with Postman”
Postman Webinar: “Continuous Testing with Postman”
Postman
 
Api Testing
Api TestingApi Testing
Api Testing
Vishwanath KC
 
Rest API Automation with REST Assured
Rest API Automation with REST AssuredRest API Automation with REST Assured
Rest API Automation with REST Assured
TO THE NEW Pvt. Ltd.
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
Rhoynar Software Consulting
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
Jason Harmon
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
Andrey Oleynik
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
Ivan Katunou
 
Cucumber & gherkin language
Cucumber & gherkin languageCucumber & gherkin language
Cucumber & gherkin language
selvanathankapilan
 

What's hot (20)

Rest assured
Rest assuredRest assured
Rest assured
 
How to Automate API Testing
How to Automate API TestingHow to Automate API Testing
How to Automate API Testing
 
Introduction to APIs & how to automate APIs testing with selenium web driver?
Introduction to APIs & how to automate APIs testing with selenium web driver?Introduction to APIs & how to automate APIs testing with selenium web driver?
Introduction to APIs & how to automate APIs testing with selenium web driver?
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj Rollison
 
Inverting The Testing Pyramid
Inverting The Testing PyramidInverting The Testing Pyramid
Inverting The Testing Pyramid
 
Postman
PostmanPostman
Postman
 
API TESTING
API TESTINGAPI TESTING
API TESTING
 
Api testing
Api testingApi testing
Api testing
 
Automation Testing With Appium
Automation Testing With AppiumAutomation Testing With Appium
Automation Testing With Appium
 
B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testing
 
Getting Started With Cypress
Getting Started With CypressGetting Started With Cypress
Getting Started With Cypress
 
RESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and JenkinsRESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and Jenkins
 
Postman Webinar: “Continuous Testing with Postman”
Postman Webinar: “Continuous Testing with Postman”Postman Webinar: “Continuous Testing with Postman”
Postman Webinar: “Continuous Testing with Postman”
 
Api Testing
Api TestingApi Testing
Api Testing
 
Rest API Automation with REST Assured
Rest API Automation with REST AssuredRest API Automation with REST Assured
Rest API Automation with REST Assured
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
 
Cucumber & gherkin language
Cucumber & gherkin languageCucumber & gherkin language
Cucumber & gherkin language
 

Viewers also liked

Presentation for soap ui
Presentation for soap uiPresentation for soap ui
Presentation for soap ui
Anjali Rao
 
SOAP-UI The Web service Testing
SOAP-UI The Web service TestingSOAP-UI The Web service Testing
SOAP-UI The Web service Testing
Ganesh Mandala
 
Soa testing soap ui (2)
Soa testing   soap ui (2)Soa testing   soap ui (2)
Soa testing soap ui (2)
Knoldus Inc.
 
Getting Started with API Security Testing
Getting Started with API Security TestingGetting Started with API Security Testing
Getting Started with API Security Testing
SmartBear
 
Testing soapui
Testing soapuiTesting soapui
Testing soapui
Shahid Shaik
 
Testing Agile Web Services from soapUI
Testing Agile Web Services from soapUITesting Agile Web Services from soapUI
Testing Agile Web Services from soapUI
PLM Mechanic .
 
An introduction to api testing | David Tzemach
An introduction to api testing | David TzemachAn introduction to api testing | David Tzemach
An introduction to api testing | David Tzemach
David Tzemach
 
Automate REST API Testing
Automate REST API TestingAutomate REST API Testing
Automate REST API Testing
TechWell
 
Ppt of soap ui
Ppt of soap uiPpt of soap ui
Ppt of soap ui
pkslide28
 
Soap ui
Soap uiSoap ui
Testing web services
Testing web servicesTesting web services
Testing web services
Taras Lytvyn
 
Learn SoapUI
Learn SoapUILearn SoapUI
Learn SoapUI
David Ionut
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI Tool
Sperasoft
 

Viewers also liked (13)

Presentation for soap ui
Presentation for soap uiPresentation for soap ui
Presentation for soap ui
 
SOAP-UI The Web service Testing
SOAP-UI The Web service TestingSOAP-UI The Web service Testing
SOAP-UI The Web service Testing
 
Soa testing soap ui (2)
Soa testing   soap ui (2)Soa testing   soap ui (2)
Soa testing soap ui (2)
 
Getting Started with API Security Testing
Getting Started with API Security TestingGetting Started with API Security Testing
Getting Started with API Security Testing
 
Testing soapui
Testing soapuiTesting soapui
Testing soapui
 
Testing Agile Web Services from soapUI
Testing Agile Web Services from soapUITesting Agile Web Services from soapUI
Testing Agile Web Services from soapUI
 
An introduction to api testing | David Tzemach
An introduction to api testing | David TzemachAn introduction to api testing | David Tzemach
An introduction to api testing | David Tzemach
 
Automate REST API Testing
Automate REST API TestingAutomate REST API Testing
Automate REST API Testing
 
Ppt of soap ui
Ppt of soap uiPpt of soap ui
Ppt of soap ui
 
Soap ui
Soap uiSoap ui
Soap ui
 
Testing web services
Testing web servicesTesting web services
Testing web services
 
Learn SoapUI
Learn SoapUILearn SoapUI
Learn SoapUI
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI Tool
 

Similar to REST API testing with SpecFlow

Examiness hints and tips from the trenches
Examiness hints and tips from the trenchesExaminess hints and tips from the trenches
Examiness hints and tips from the trenches
Ismail Mayat
 
Bridging the gap from Wikipedia to scholarly sources: a simple discovery solu...
Bridging the gap from Wikipedia to scholarly sources: a simple discovery solu...Bridging the gap from Wikipedia to scholarly sources: a simple discovery solu...
Bridging the gap from Wikipedia to scholarly sources: a simple discovery solu...
Valerie Forrestal
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
Erik Hatcher
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
Erik Hatcher
 
Rest web services
Rest web servicesRest web services
Rest web services
Paulo Gandra de Sousa
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
Samantha Geitz
 
SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development Overview
Rob Windsor
 
MVS: An angular MVC
MVS: An angular MVCMVS: An angular MVC
MVS: An angular MVC
David Rodenas
 
Apache Calcite (a tutorial given at BOSS '21)
Apache Calcite (a tutorial given at BOSS '21)Apache Calcite (a tutorial given at BOSS '21)
Apache Calcite (a tutorial given at BOSS '21)
Julian Hyde
 
Start testing your extension NOW
Start testing your extension NOWStart testing your extension NOW
Start testing your extension NOW
Jan Helke
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
Mykhailo Kolesnyk
 
Rapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxRapid API Development ArangoDB Foxx
Rapid API Development ArangoDB Foxx
Michael Hackstein
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
Ricardo Peres
 
SPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePointSPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePoint
Mark Rackley
 
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
dnaber
 
Apache Lucene Searching The Web
Apache Lucene Searching The WebApache Lucene Searching The Web
Apache Lucene Searching The Web
Francisco Gonçalves
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Tips and Tricks for Building Visual Studio Workflows
Tips and Tricks for Building Visual Studio WorkflowsTips and Tricks for Building Visual Studio Workflows
Tips and Tricks for Building Visual Studio Workflows
Malin De Silva
 
Powershell Training
Powershell TrainingPowershell Training
Powershell Training
Fahad Noaman
 
Drupal & Summon: Keeping Article Discovery in the Library
Drupal & Summon: Keeping Article Discovery in the LibraryDrupal & Summon: Keeping Article Discovery in the Library
Drupal & Summon: Keeping Article Discovery in the Library
Ken Varnum
 

Similar to REST API testing with SpecFlow (20)

Examiness hints and tips from the trenches
Examiness hints and tips from the trenchesExaminess hints and tips from the trenches
Examiness hints and tips from the trenches
 
Bridging the gap from Wikipedia to scholarly sources: a simple discovery solu...
Bridging the gap from Wikipedia to scholarly sources: a simple discovery solu...Bridging the gap from Wikipedia to scholarly sources: a simple discovery solu...
Bridging the gap from Wikipedia to scholarly sources: a simple discovery solu...
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Rest web services
Rest web servicesRest web services
Rest web services
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
 
SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development Overview
 
MVS: An angular MVC
MVS: An angular MVCMVS: An angular MVC
MVS: An angular MVC
 
Apache Calcite (a tutorial given at BOSS '21)
Apache Calcite (a tutorial given at BOSS '21)Apache Calcite (a tutorial given at BOSS '21)
Apache Calcite (a tutorial given at BOSS '21)
 
Start testing your extension NOW
Start testing your extension NOWStart testing your extension NOW
Start testing your extension NOW
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Rapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxRapid API Development ArangoDB Foxx
Rapid API Development ArangoDB Foxx
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
SPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePointSPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePoint
 
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
 
Apache Lucene Searching The Web
Apache Lucene Searching The WebApache Lucene Searching The Web
Apache Lucene Searching The Web
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Tips and Tricks for Building Visual Studio Workflows
Tips and Tricks for Building Visual Studio WorkflowsTips and Tricks for Building Visual Studio Workflows
Tips and Tricks for Building Visual Studio Workflows
 
Powershell Training
Powershell TrainingPowershell Training
Powershell Training
 
Drupal & Summon: Keeping Article Discovery in the Library
Drupal & Summon: Keeping Article Discovery in the LibraryDrupal & Summon: Keeping Article Discovery in the Library
Drupal & Summon: Keeping Article Discovery in the Library
 

Recently uploaded

Tailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer InsightsTailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer Insights
SynapseIndia
 
How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...
DianaGray10
 
Uncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in LibrariesUncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in Libraries
Brian Pichman
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
Shiv Technolabs
 
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
Priyanka Aash
 
Patch Tuesday de julio
Patch Tuesday de julioPatch Tuesday de julio
Patch Tuesday de julio
Ivanti
 
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
Priyanka Aash
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
Google Developer Group - Harare
 
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision MakingConnector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
DianaGray10
 
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and DisadvantagesBLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
SAI KAILASH R
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
AmandaCheung15
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
maigasapphire
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
bellared2
 
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
Priyanka Aash
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
BrainSell Technologies
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
SynapseIndia
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Muhammad Ali
 
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
shanihomely
 
Feature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptxFeature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptx
ssuser1915fe1
 
Mastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for SuccessMastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for Success
David Wilson
 

Recently uploaded (20)

Tailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer InsightsTailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer Insights
 
How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...
 
Uncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in LibrariesUncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in Libraries
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
 
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
 
Patch Tuesday de julio
Patch Tuesday de julioPatch Tuesday de julio
Patch Tuesday de julio
 
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
 
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision MakingConnector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
 
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and DisadvantagesBLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
 
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
 
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
 
Feature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptxFeature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptx
 
Mastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for SuccessMastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for Success
 

REST API testing with SpecFlow

  • 1. REST API testing with SpecFlow Aistė Stikliūtė @ Visma Lietuva
  • 2. Agenda Why SpecFlow REST API How to Details & tips Live demo Bonus: other uses of SpecFlow
  • 3. Why SpecFlow • SoapUI? • Fitnesse? • Cucumber?
  • 4. Why not…  SoapUI  Free version issues  Tests less easy to read  Thought there was no CI  Fitnesse  Works poorly with .NET  Wiki markup and tables interface is tiring  Cucumber  Yes – SpecFlow is Cucumber for .NET!
  • 6. BDD / Gherkin language GIVEN book with ISBN “1-84356-028-3” is in the system AND it’s available quantity is 9 WHEN I add a book with ISBN “1-84356-028-3” THEN the book is successfully added to the list AND available qty. for book with ISBN “1-84356-028-3” is 10
  • 7. The environment Same tool as for GUI tests (Visual Studio, C#) Same solution as GUI tests and even the whole system Convenient! Developers are integrated!
  • 8. Rest API • What it is • Examples • Why test it
  • 9. REST API  Web architectural style with a set of constraints  Web service APIs that adhere to the constraints - RESTful Frontend REST API Backend External system(s) External system(s)
  • 10. Rest API: typically used HTTP methods Resource GET PUT POST DELETE Collection URI, such as http://example.com/res ources List collection's members Replace collection with another collection Create new entry in the collection Delete the entire collection Element URI, such as http://example.com/res ources/item17 Retrieve the member of the collection Replace the member of the collection Not generally used Delete the member of the collection
  • 11. Example 1 Request  GET https://eshop.com/books/14765 Response  Status: 200 OK { "id": “14765", “title": “Game of Thrones", “author": “George R. R. Martin", “isbn": "1-84356-028-3", “availableQty": “4" }
  • 12. Example 2 Request  POST https://eshop.com/books { “title": “501 Spanish Verbs", “author": “C. Kendris", “isbn": "1-84750-018-7", “availableQty": “10" } Response  Status: 200 OK { “id": “78953“ }
  • 13. Example 3 Requests  DELETE https://eshop.com/book/84523  GET https://eshop.com/admin  PUT https://eshop.com/book/24552 { [some wrong data] } Responses  Status: 200 OK  Status: 401 Unauthorized  Status: 500 Internal Server Error
  • 14. Why test Rest API?  If used by external applications: this is your UI!  As your system layer:  Can help find / isolate problems: Security Performance Robustness Functionality  May be more simple to test / automate than GUI tests
  • 16. Step 1: know what your API should do  Documentation  Talk to developers  Browser’s Developer tools  REST client (e.g. Postman on Chrome)
  • 17. Dev tools + REST client
  • 18. Step 2: write your test scenarios  ListBooks.feature Scenario: There are no books in the system Given there are no books in the system When I retrieve list of all books Then I get empty list Scenario: There are less books than fit into 1 page Scenario: There are more books than fit into 1 page Scenario: Sort books Scenario: Search for a book
  • 19. Step 3: generate scenario steps [Given(@”there are no books in the list”)] public void GivenThereAreNoBooksInTheList() { ScenarioContext.Current.Pending(); }
  • 20. Step 4: implement scenario steps  Here‘s where the Rest API calls go!  Plain C# can be used or libraries // I use RestSharp  Structure your project
  • 21. Project structure  Features: all features, can have subfolders  Steps: bindings of features to actions  Actions: where things happen  Helpers: among others, RestHelper.cs  Model: classes matching our API data format  App.config: holds base URI
  • 22. A quick look into code: Steps & Actions Steps Actions
  • 23. A quick look into code: Model
  • 24. A quick look into code: RestHelper.cs
  • 25. Step 5: run tests
  • 26. Step 6: add to Continuous Integration
  • 28. Hooks (event bindings)  Before / after test run  static  Before / after feature  static  Before / after scenario  Before / after scenario block (given / when / then)  Before / after step
  • 29. Step scope and reusing  Steps are global!  Naming: “when I update it”  “when I update the book”  Scoped bindings: [Scope(Tag="my tag", Feature=“my feature", Scenario=“my scenario")]  Reusing step in other steps [Given(@"(.*) is logged in")] public void GivenIsLoggedIn(string name) { Given(string.Format("the user {0} exists", name)); Given(string.Format("I log in as {0}", name)); }
  • 30. Table and multiline step arguments
  • 32. Bonus Other uses of SpecFlow
  • 33. Behaviour / Business Driven Development 1. PO / QA writes scenarios 2. Developer writes unit/integration tests 3. Developer writes code until tests pass
  • 34. Driving Selenium tests Scenario: Successful login Given I am at http://eshop.com/login When I login with user “John” and password “Password1” Then I am redirected to http://eshop.com/main Scenario: Successful login Given I am in login page When I login with correct credentials Then I am redirected to main page
  • 35. SpecFlow & Selenium using scoped bindings [When(@"I perform a simple search on '(.*)'", Scope(Tag = “api"))] public void WhenIPerformASimpleSearchOn(string searchTerm) { var api = new CatalogApi(); actionResult = api.Search(searchTerm); } [When(@"I perform a simple search on '(.*)'"), Scope(Tag = "web")] public void PerformSimpleSearch(string title) { selenium.GoToThePage("Home"); selenium.Type("searchTerm", title); selenium.Click("searchButton"); }
  • 36. Test case management / Test reporting  One functional test suite?  Manual  Automated API  Automated GUI  One report with test list that can be read by  POs and manual QAs  management  customer
  • 37. Thank you! Time for questions 

Editor's Notes

  1. Client-server, stateless, cacheable, layered system, code on demand (client-side, optional), uniform interface: identification of resources, manipulation of resources, self-descriptive messages, hypermedia as the engine of the application state.
  2. If I don’t see it in the UI but can access through API – it’s not secured good enough! Unnecessary API calls made / too much info returned – performance Misuse of the API finds bugs (insert duplicate record  error retrieving list) Fields you don’t see in UI may be wrong, or just looking from another point of view helps find bugs
  3. In SpecFlow, test scenarios are grouped by features into dedicated feature files Good example why API needs to be tested. It may be implemented the way that API returns and error if there are no books, but it should be an empty list based on RESTful constraints. GUI might simply display no books if there‘s an error, so you will think all is good. Then you might also wonder if it‘s OK that API returns an error but API doesn‘t show it.
  4. Binding to feature is an anti-pattern, but there are other good uses to scoped bindings, like tags for differentiating between API and GUI tests Reusing like in this example is for making our steps shorter. In test console we’ll see inner steps. So far I haven’t used this as I found moving out Rest API calls to separate classes is enough, but I can see where it would make sense to use it.
  5. API testing is just one possible use of SpecFlow
  6. And in Steps all Webdriver logic can be placed. PageObject pattern can still be used at it’s fullest. For example, just the way we have Model classes, we can have Page classes. The slide shows the style that should not and should be used in scenarios.