StoryLine is testing framework created using .NET Core. Framework provides fluent syntax which can be used to write system and sub-system test for REST services.
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
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)
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
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.