-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DMS-376] Adding readme files, cleanup code, appsettings.json
Signed-off-by: Moises Siles <[email protected]>
- Loading branch information
Showing
6 changed files
with
112 additions
and
17 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...msConfigurationService.Frontend.AspNetCore.ContractTest.ConsumerTests/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Consumer Tests | ||
|
||
Pact is a consumer-driven contract testing tool, meaning the API consumer | ||
defines a test outlining its expectations and requirements from the API | ||
provider(s). By unit testing the API client with Pact, we generate a contract | ||
that can be shared with the provider to validate these expectations and help | ||
prevent breaking changes. | ||
|
||
## Running The Consumer Tests | ||
|
||
Run the tests how you run any other test suite. For example: | ||
|
||
- Visual Studio Test Explorer | ||
- from `/src/config/frontend/...ConsumerTests/tests` run: `dotnet test`. | ||
- Once the test are executed you will find a new file inside the `/pacts/` | ||
folder, this folder contains a json file which is the contract used for the | ||
provider tests | ||
|
||
## Generate the Contract | ||
|
||
PactNet will automatically generate a Pact file after running the test, | ||
typically saved to the `/pacts/` folder. This Pact file is the contract your | ||
consumer expects from the provider. | ||
|
||
## Share the Pact file with the Provider | ||
|
||
Share the generated Pact file with the provider for their own verification, | ||
often by storing it in a Pact Broker or a shared repository. | ||
|
||
This approach allows you to create a consumer-driven contract that the provider | ||
can validate to prevent any breaking changes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...msConfigurationService.Frontend.AspNetCore.ContractTest.ProviderTests/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Provider Tests | ||
|
||
Provider tests in contract testing verify that the provider (API server) meets | ||
the expectations defined by the consumer in the contract (Pact file). These | ||
tests ensure the provider adheres to the contract, helping prevent breaking | ||
changes for the consumer. | ||
|
||
## Running The Provider Tests | ||
|
||
Run the tests how you run any other test suite. For example: | ||
|
||
- Visual Studio Test Explorer | ||
- from `/src/config/frontend/...ProviderTests/tests` run: `dotnet test`. | ||
|
||
> [!IMPORTANT] | ||
Pact contract verification includes a single test in the code, using | ||
> only one .verify method from Pact to run the contract-based tests. If any | ||
> failures occur, an error will be displayed in the terminal, and the test | ||
> framework will show a single failure result. To view the details of these | ||
> failures, you’ll need to scroll up in the terminal output. | ||
## Key Steps in contract testing | ||
|
||
### Setup Pact Verification | ||
|
||
The provider test will read the consumer's Pact file, usually stored in a Pact | ||
Broker or as a local file, to retrieve the expected interactions. This file | ||
defines the requests that the provider should handle and the corresponding | ||
responses the consumer expects. | ||
|
||
### Configure the provider Test | ||
|
||
In the provider tests, configure the Pact verifier to: | ||
|
||
- Specify the provider details (e.g., name and base URL). | ||
- Specify the Pact source, currently we are not using the Pact Broker feature. | ||
Pact File should be specified in the Provider Test. | ||
- Specify the provider states url, make sure url matches the PactBase URL. | ||
|
||
### Running the Provider Test and Verify Interactions | ||
|
||
The Pact verifier sends the requests to the provider based on the interactions | ||
in the Pact file and checks that the provider responds with the expected | ||
responses. Each test run will verify that the provider's responses match the | ||
expected responses, as defined in the contract. | ||
|
||
## Share the Pact file with the Provider | ||
|
||
Share the generated Pact file with the provider for their own verification, in | ||
our case we are storing the Pact File in the repo. | ||
|
||
This approach allows you to create a consumer-driven contract that the provider | ||
can validate to prevent any breaking changes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters