SlideShare uma empresa Scribd logo
1 de 37
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 

Mais conteúdo relacionado

Mais procurados

Mais procurados (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
 
Api testing
Api testingApi testing
Api testing
 
Test automation process
Test automation processTest automation process
Test automation process
 
API Testing With Katalon Studio
API Testing With Katalon StudioAPI Testing With Katalon Studio
API Testing With Katalon Studio
 
Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)
 
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
 
Automation Testing
Automation TestingAutomation Testing
Automation Testing
 
B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testing
 
Automated UI Testing
Automated UI TestingAutomated UI Testing
Automated UI Testing
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and Selenium
 
Postman. From simple API test to end to end scenario
Postman. From simple API test to end to end scenarioPostman. From simple API test to end to end scenario
Postman. From simple API test to end to end scenario
 
API Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberAPI Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+Cucumber
 
API Test Automation
API Test Automation API Test Automation
API Test Automation
 
Api Testing
Api TestingApi Testing
Api Testing
 
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
 
Test api
Test apiTest api
Test api
 
Accelerate Quality with Postman - Basics
Accelerate Quality with Postman - BasicsAccelerate Quality with Postman - Basics
Accelerate Quality with Postman - Basics
 
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
 
Api testing
Api testingApi testing
Api testing
 

Destaque

Ppt of soap ui
Ppt of soap uiPpt of soap ui
Ppt of soap ui
pkslide28
 

Destaque (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
 
Automate REST API Testing
Automate REST API TestingAutomate REST API Testing
Automate REST API Testing
 
4 Major Advantages of API Testing
4 Major Advantages of API Testing4 Major Advantages of API Testing
4 Major Advantages of 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
 

Semelhante a REST API testing with SpecFlow

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
 
SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development Overview
Rob Windsor
 
Rapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxRapid API Development ArangoDB Foxx
Rapid API Development ArangoDB Foxx
Michael Hackstein
 
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
 
Powershell Training
Powershell TrainingPowershell Training
Powershell Training
Fahad Noaman
 

Semelhante a 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
Apache Lucene Searching The WebApache Lucene Searching The Web
Apache Lucene Searching The Web
 
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)
 
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
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

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 

Notas do Editor

  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.