Prerequisites
In order to start work on component tests the following components should be installed:

Description of this structure can be found below
In order to start work on component tests the following components should be installed:
- StoryLine packages:
- StoryLine https://www.nuget.org/packages/StoryLine/
- StoreLine.Rest https://www.nuget.org/packages/StoryLine.Rest/
- StoreLine.Wiremock https://www.nuget.org/packages/StoryLine.Wiremock/
- Wiremock application:
- You can install this application directly: http://wiremock.org/
- I would recommnd to use Docker image to simplify installation process
- Fluent Assertions https://www.nuget.org/packages/FluentAssertions/
Solution structure
The following component test project structure is suggested:
Description of this structure can be found below
- {Service Project Name}.ComponentTests Project which contains tests for microservice project
- Helpers This folder contains reusable components used to build test scenarios
- v1 version of API which is tested by test cases located in this folder.
- Models Folder contains definitions of DTOs used to send\receive data to\from microservice
- Resources Folder contains test cases for each API resource
- {Resource Name} Name of resource which is tested by tests inside folder
- {API action name} Name API method. This can be create, update, delete or any other action which is exposed by REST endpoint. For example POST http://myservice.com/v1/users or GET http://myservice.com/v1/users/{userId}
- Swagger This folder contains tests for swagger documentation exposed by microservice
- Docs Name of resource exposing swagger document
- Get.cs Tests for HTTP get action verifying that requested swagger matches saved document definition. This test is required to make sure that service contract doesn't change without notice.
- ApiTestBase.cs is base class for all tests. It contains common logic shared by all tests. In most cases this is just Wiremock configuration reset. This action is required to make sure that previous test case doesn't affect current one.
- Config.cs is test initializer which performs one time setup for all test cases. These actions may include creation of external entities used by all tests, reading settings from configuration file and etc.
Comments
Post a Comment