WireMock.Net
dotnet-testcontainers
Our great sponsors
WireMock.Net | dotnet-testcontainers | |
---|---|---|
9 | 6 | |
1,293 | 1,129 | |
3.9% | - | |
8.6 | 7.3 | |
8 days ago | almost 2 years ago | |
C# | C# | |
Apache License 2.0 | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
WireMock.Net
-
Mock heavy tests
I'd say that without wanting to refactor the code a little bit (maybe moving those HttpClients into a service so that they are easily mocked) your best bet would be to use something like WireMock or MockHttp.
-
Please recommend a good API Mocking tool
WireMock
-
Usefully links for DotNet Backend Developers
WiremockNet https://github.com/WireMock-Net/WireMock.Net
-
Integration tests without API dependencies with ASP.NET Core and WireMock.Net
In this post, I'll explain how to create mocks for HTTP APIs in narrow integration tests using the WireMock.Net library.
-
Fake apis for testing
Recently was pointed to WireMock for testing purposes.
-
How do you Unit Test a WebAPI? What do you test?
I use WireMock (@ Java) to start a local webserver alongside the tests, this webserver will provide ‘real’ responses to the client. Here’s the C# equivalent: https://github.com/WireMock-Net/WireMock.Net
- Capturing Http requests for testing purposes
-
How do I mock the response from my authentication server for client integration tests?
You could try out WireMock.Net: https://github.com/WireMock-Net/WireMock.Net/wiki/Using-WireMock-in-UnitTests
-
The only way to go fast, is to go well (TDD from Factorio)
Use WireMock to mock responses from the endpoint that FooClient interacts with. This lets you exercise all of the code contained in FooClient in a realistic way, without using mocks, but still get the different responses you expect.
dotnet-testcontainers
-
How do you Unit Test a WebAPI? What do you test?
So what I usually do is: • Unit test underlying (public) services and application ‘core’ • Integration test (or w/e you call it) an entire functionality flow, by sending in ‘real’ requests on one end, and locally mocking/stubbing the application ‘edges’ that supply the response data. WireMock for requests to external services, H2 or Testcontainers for database.
-
EF Core In-Memory DB (for testing) does not allow List<int> property even though this is something Postgres does. How would I go about testing this?
I'd use testcontainers to spin up an instance of Progress and run against the actual thing. That way you get the benefit of testing against the actual database, but also that you don't have to set up a bunch of stuff locally.
Not every db support array as primitive, if you want to write integration tests and you have access to docker I suggest you testcontainers.
-
Does anyone have a good functional (integration? end to end?) automated Web API testing setup?
There is a rope which can help with this task: https://github.com/HofmeisterAn/dotnet-testcontainers
-
Integration testing with EF Core, part 2
Dotnet.Testcontainers also comes with some built-in classes that wraps various services, one of these classes actually wraps a SQL Server Docker container and there are few more that covers the most common databases e.g.
-
End to end testing is confusing
You should also check out Docker, especially TestContainers. That way you can spin up databases (and other dependencies) on the fly and do operations on them. This means that you don't need to "fake" a database, as you will have access to a new one.
What are some alternatives?
Moq - Repo for managing Moq 4.x [Moved to: https://github.com/moq/moq]
FluentDocker - Use docker, docker-compose local and remote in tests and your .NET core/full framework apps via a FluentAPI
mockhttp - Testing layer for Microsoft's HttpClient library. Create canned responses using a fluent API.
NUnit - NUnit Framework
SpecFlow - #1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
xUnit - xUnit.net is a free, open source, community-focused unit testing tool for .NET.
harbor - Dotnet CLI tool to help easily handling development dependencies
Fluent Assertions - A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.7, as well as .NET Core 2.1, .NET Core 3.0, .NET 6, .NET Standard 2.0 and 2.1. Supports the unit test frameworks MSTest2, NUnit3, XUnit2, MSpec, and NSpec3.
LocalDb - Provides a wrapper around SqlLocalDB to simplify running tests or samples that require a SQL Server Database
FakeItEasy - The easy mocking library for .NET
marionette - Marionette is a test automation framework based on image and text recognition for .NET.