SlideShare ist ein Scribd-Unternehmen logo
1 von 25
StoryLine
.NET Core test framework to write REST API tests
About me
 Andrei Salanoi
 .NET Division Manager / .NET Architect
 Godel Technologies Europe
 Microsoft Certified Solution Developer
 13+ years of experience in Software Development
Agenda
 Reason to create StoryLine
 Naive approach to write REST API tests
 StoryLine overview
 StoryLine key concepts
 FAQ
Reason to create StoryLine
 Our project uses proprietary library which is not available for wide audience
 There is no similar solution which can be used for .NET Core and optionally
for full .NET Framework
 There is a need to create testing framework which has clear separation of
concerns
 There is a need to create framework which supports modularity and can be
used for medium and big projects
 There is a need to create framework which can be used to write system and
sub-system tests
Naïve approach to write REST API tests
 Create test project
 Add code similar to this:
 Or even something like this:
Issues with naïve approach
 Complexity of test support grows exponentially.
 Intentions of tests methods are not clear as soon as majority of code is
related to construction of HTTP request.
 Poor modularity of tests.
 Test development becomes a pain very soon.
 No way to analyze REST API coverage (verbs, urls, response codes and MIME
types).
Better way to write REST API tests
 One of possible alternatives might be usage of StoryLine framework:
Benefits of StoryLine
 Declarative syntax of scenarios
 Modularity of actions and expectations
 Separation of concerns via usage of ActionsExpectations and builders
 Open source code which is available on GitHub
 NuGet packages available on NuGet.org
 Ease of use and development
Supported frameworks
 The following frameworks are supported by StoryLine:
 .NET Core 1.1+
 .NET Framework 4.6+
StoryLine – Key concepts
 Actions and action builders
 Expectations and expectation builders
 Actors and artifact collection
StoryLine – Key Concepts
StoryLine framework libraries
StoryLine – Framework core
 Base interfaces and syntax of framework
 Support of lazy-load actions and scenarios
 Scenario runner and scenario event handlers invoker
StoryLine.Rest – HTTP actions and
expectations
 HTTP request builder action:
 Ability to specify HTTP method, headers, url, query string params
 Ability to construct request body (JSON, Plain text, Form data)
 HTTP request expectation
 Validation of response status code, headers, reason phrases
 Extended support of body validation (JSON, Plain text)
StoryLine.Rest – Usage
StoryLine.Rest – Demo
 Membership microservice
 CRUD API
 In-memory data storage
 Subsystem tests for CRUD API
StoryLine.Wiremock – Wiremock client
 Client library for HTTP request stubbing tool
 Actions and expectations compatible with StoryLine
StoryLine.Wiremock - Usage
StoryLine.Wiremock – Demo
 Gateway microservice:
 Interacts with two microservices (stubbed by wiremock)
 No state is stored by microservice
 Wiremock service
StoryLine.Utils – Reusable helper actions
and expectations
 Transformation actions to support artifacts of different types
 Artifact-specific expectations
Appendix A: Links
 StoryLine framework source code:
 https://github.com/DiamondDragon/StoryLine
 https://github.com/DiamondDragon/StoryLine.Rest
 https://github.com/DiamondDragon/StoryLine.Wiremock
 https://github.com/DiamondDragon/StoryLine.Utils
 StoryLine NuGet packages
 https://www.nuget.org/packages/StoryLine/
 https://www.nuget.org/packages/StoryLine.Rest/
 https://www.nuget.org/packages/StoryLine.Wiremock/
 https://www.nuget.org/packages/StoryLine.Utils/
 Wiremock:
 http://wiremock.org/
Appendix B: Examples
 Membership microservice and subsystem tests:
 https://github.com/DiamondDragon/StoryLine.Rest/tree/master/Examples
 Gatway microservice and subsystem tests
 https://github.com/DiamondDragon/StoryLine.Wiremock/tree/master/Examples
Appendix B: FAQ
 What tools can be used to run tests? Any .NET test framework: NUnit, XUnit,
MsTest. No custom test runner is required.
 How to group tests into categories? Grouping is expected to be done by
[Trait] of XUnit or [Category] of NUnit.
 Is multithreaded execution supported? This kind of execution is not
explicitly forbidden but some libraries (StoryLine.Wiremock) may not work as
expected when multiple tests are executed against the same mock server.
Answer might also be dependent on actions used by test scenario. Potential
issues described above must be taken into consideration.
 Integration with BDD? Framework can be used in BDD (there are no
fundamental issues with this). One of the reasons to define framework as it
now was to avoid extra abstraction layers as BDD frameworks.
Appendix B: FAQ
 What tools can be used to generate reports? As soon as StoryLine runs on top of
NUnit, XUnit, MsTest report generation is dependent on selected tool.
 Is SOAP supported? No. There is no support of SOAP at the moment. This protocol
is not so popular as REST at the moment. At the same time custom SOAP-specific
actions can be created. There are no fundamental issues with this.
 Is HTTPS supported? Yes. No special configuration is required to work with HTTPS.
HTTP communication is implemented using HttpClient which works equally good
with HTTP and HTTPS.
 How test data can be generated? There is no custom data generator available.
There are a lot of good libraries which can be added to test project: GetFu,
AutoFixture.
 Does error contain enough information? Actions included into StoryLine.*
libraries provide detailed error messages. Custom actionsexpectations created by
developers are responsible for proper error reporting.
Thank you for you attention! =)

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (10)

How we tested our code "Google way"
How we tested our code "Google way"How we tested our code "Google way"
How we tested our code "Google way"
 
2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assured2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assured
 
Generic Test Automation Architecture
Generic Test Automation ArchitectureGeneric Test Automation Architecture
Generic Test Automation Architecture
 
Azure DevOps for the Data Professional
Azure DevOps for the Data ProfessionalAzure DevOps for the Data Professional
Azure DevOps for the Data Professional
 
ASP.NET security vulnerabilities
ASP.NET security vulnerabilitiesASP.NET security vulnerabilities
ASP.NET security vulnerabilities
 
Unit Testing in Swift
Unit Testing in SwiftUnit Testing in Swift
Unit Testing in Swift
 
What is .Net Standard
What is .Net StandardWhat is .Net Standard
What is .Net Standard
 
Codeigniter Introduction
Codeigniter IntroductionCodeigniter Introduction
Codeigniter Introduction
 
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
 
GNUCITIZEN Dwk Owasp Day September 2007
GNUCITIZEN Dwk Owasp Day   September 2007GNUCITIZEN Dwk Owasp Day   September 2007
GNUCITIZEN Dwk Owasp Day September 2007
 

Ähnlich wie Story line

D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
Sunil Patil
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
Sunil Patil
 
Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack Discussion
Zaiyang Li
 

Ähnlich wie Story line (20)

PHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codePHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the code
 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)
 
Monitoring as an entry point for collaboration
Monitoring as an entry point for collaborationMonitoring as an entry point for collaboration
Monitoring as an entry point for collaboration
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web Application
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
ArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudArcReady - Architecting For The Cloud
ArcReady - Architecting For The Cloud
 
Innovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC IntegrationsInnovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC Integrations
 
Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack Discussion
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Oscon
 
Comparing the Key Features of the Top Node.js Frameworks
Comparing the Key Features of the Top Node.js FrameworksComparing the Key Features of the Top Node.js Frameworks
Comparing the Key Features of the Top Node.js Frameworks
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
 
Azure presentation nnug dec 2010
Azure presentation nnug  dec 2010Azure presentation nnug  dec 2010
Azure presentation nnug dec 2010
 
From Monoliths to Microservices at Realestate.com.au
From Monoliths to Microservices at Realestate.com.auFrom Monoliths to Microservices at Realestate.com.au
From Monoliths to Microservices at Realestate.com.au
 
Resume_Vinay_Singh_Dot_Net_Dev
Resume_Vinay_Singh_Dot_Net_DevResume_Vinay_Singh_Dot_Net_Dev
Resume_Vinay_Singh_Dot_Net_Dev
 
SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011
 
SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011
 
What's New in .Net 4.5
What's New in .Net 4.5What's New in .Net 4.5
What's New in .Net 4.5
 
Real-Time Web Applications with ASP.NET WebAPI and SignalR
Real-Time Web Applications with ASP.NET WebAPI and SignalRReal-Time Web Applications with ASP.NET WebAPI and SignalR
Real-Time Web Applications with ASP.NET WebAPI and SignalR
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

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...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
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...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 

Story line

  • 1. StoryLine .NET Core test framework to write REST API tests
  • 2. About me  Andrei Salanoi  .NET Division Manager / .NET Architect  Godel Technologies Europe  Microsoft Certified Solution Developer  13+ years of experience in Software Development
  • 3. Agenda  Reason to create StoryLine  Naive approach to write REST API tests  StoryLine overview  StoryLine key concepts  FAQ
  • 4. Reason to create StoryLine  Our project uses proprietary library which is not available for wide audience  There is no similar solution which can be used for .NET Core and optionally for full .NET Framework  There is a need to create testing framework which has clear separation of concerns  There is a need to create framework which supports modularity and can be used for medium and big projects  There is a need to create framework which can be used to write system and sub-system tests
  • 5. Naïve approach to write REST API tests  Create test project  Add code similar to this:  Or even something like this:
  • 6. Issues with naïve approach  Complexity of test support grows exponentially.  Intentions of tests methods are not clear as soon as majority of code is related to construction of HTTP request.  Poor modularity of tests.  Test development becomes a pain very soon.  No way to analyze REST API coverage (verbs, urls, response codes and MIME types).
  • 7. Better way to write REST API tests  One of possible alternatives might be usage of StoryLine framework:
  • 8. Benefits of StoryLine  Declarative syntax of scenarios  Modularity of actions and expectations  Separation of concerns via usage of ActionsExpectations and builders  Open source code which is available on GitHub  NuGet packages available on NuGet.org  Ease of use and development
  • 9. Supported frameworks  The following frameworks are supported by StoryLine:  .NET Core 1.1+  .NET Framework 4.6+
  • 10. StoryLine – Key concepts  Actions and action builders  Expectations and expectation builders  Actors and artifact collection
  • 11. StoryLine – Key Concepts
  • 13. StoryLine – Framework core  Base interfaces and syntax of framework  Support of lazy-load actions and scenarios  Scenario runner and scenario event handlers invoker
  • 14. StoryLine.Rest – HTTP actions and expectations  HTTP request builder action:  Ability to specify HTTP method, headers, url, query string params  Ability to construct request body (JSON, Plain text, Form data)  HTTP request expectation  Validation of response status code, headers, reason phrases  Extended support of body validation (JSON, Plain text)
  • 16. StoryLine.Rest – Demo  Membership microservice  CRUD API  In-memory data storage  Subsystem tests for CRUD API
  • 17. StoryLine.Wiremock – Wiremock client  Client library for HTTP request stubbing tool  Actions and expectations compatible with StoryLine
  • 19. StoryLine.Wiremock – Demo  Gateway microservice:  Interacts with two microservices (stubbed by wiremock)  No state is stored by microservice  Wiremock service
  • 20. StoryLine.Utils – Reusable helper actions and expectations  Transformation actions to support artifacts of different types  Artifact-specific expectations
  • 21. Appendix A: Links  StoryLine framework source code:  https://github.com/DiamondDragon/StoryLine  https://github.com/DiamondDragon/StoryLine.Rest  https://github.com/DiamondDragon/StoryLine.Wiremock  https://github.com/DiamondDragon/StoryLine.Utils  StoryLine NuGet packages  https://www.nuget.org/packages/StoryLine/  https://www.nuget.org/packages/StoryLine.Rest/  https://www.nuget.org/packages/StoryLine.Wiremock/  https://www.nuget.org/packages/StoryLine.Utils/  Wiremock:  http://wiremock.org/
  • 22. Appendix B: Examples  Membership microservice and subsystem tests:  https://github.com/DiamondDragon/StoryLine.Rest/tree/master/Examples  Gatway microservice and subsystem tests  https://github.com/DiamondDragon/StoryLine.Wiremock/tree/master/Examples
  • 23. Appendix B: FAQ  What tools can be used to run tests? Any .NET test framework: NUnit, XUnit, MsTest. No custom test runner is required.  How to group tests into categories? Grouping is expected to be done by [Trait] of XUnit or [Category] of NUnit.  Is multithreaded execution supported? This kind of execution is not explicitly forbidden but some libraries (StoryLine.Wiremock) may not work as expected when multiple tests are executed against the same mock server. Answer might also be dependent on actions used by test scenario. Potential issues described above must be taken into consideration.  Integration with BDD? Framework can be used in BDD (there are no fundamental issues with this). One of the reasons to define framework as it now was to avoid extra abstraction layers as BDD frameworks.
  • 24. Appendix B: FAQ  What tools can be used to generate reports? As soon as StoryLine runs on top of NUnit, XUnit, MsTest report generation is dependent on selected tool.  Is SOAP supported? No. There is no support of SOAP at the moment. This protocol is not so popular as REST at the moment. At the same time custom SOAP-specific actions can be created. There are no fundamental issues with this.  Is HTTPS supported? Yes. No special configuration is required to work with HTTPS. HTTP communication is implemented using HttpClient which works equally good with HTTP and HTTPS.  How test data can be generated? There is no custom data generator available. There are a lot of good libraries which can be added to test project: GetFu, AutoFixture.  Does error contain enough information? Actions included into StoryLine.* libraries provide detailed error messages. Custom actionsexpectations created by developers are responsible for proper error reporting.
  • 25. Thank you for you attention! =)