-
-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save proxied requests during an XUnit integration test? #1066
Comments
I had a quick look and I don't think that's what I'm looking for. Will review more closely soon and post a sample with more precise details if the the above is indeed not what I'm after. Thanks for the response and will keep you posted. |
@dahlsailrunner : did you time to verify? |
I have not but should have time this week. Thanks for the reminder here - I will let you know by Sunday for sure. |
I checked - I don't think it does what I'm looking for but I've got a repo that lays things out (and tried the admin api rest client too). I'm fairly certain you should be able to clone this repo: https://github.com/dahlsailrunner/automation-testing-strategies-aspnet/tree/main and then run/debug the tests. The The code that invokes the WireMock call starts in the If you put a breakpoint in the I was actually trying to get the proxied calls saved to a file but couldn't find the file(s) anywhere after the test run. If there's a way to do this, it would be great. Then we could "run a test against the API", then use the recorded API test calls as the wiremock back end for at least some of the tests from a UI that calls the API that was just tested. Thanks in advance for any help / guidance here. |
I did have a quick look, however I don't understand yet what you are trying to test, because when I comment out WireMock, all tests still work fine? Like: public string ProxyAndRecordApiCalls(Uri apiBaseUrl)
{
var settings = new WireMockServerSettings
{
StartAdminInterface = true,
// FileSystemHandler = new TestLocalFileSystemHandler()
};
var server = WireMockServer.Start(settings);
_mockServerUrl = server.Url!;
//server.Given(Request.Create().WithPath("*"))
// .RespondWith(Response.Create().WithProxy(
// new ProxyAndRecordSettings
// {
// Url = apiBaseUrl.ToString(),
// //FileSystemHandler = new TestLocalFileSystemHandler()
// SaveMapping = true,
// SaveMappingToFile = true
// }));
return _mockServerUrl;
} |
I'm trying to record the calls in the test. Then use those calls later. There is no need for wire mock in this set of tests other than to record the calls for a test that will use these calls (with WireMock) -- recording this test would simply let me avoid hand-coding the mapping. Does that make sense? |
I have an API that I have written integration tests for using XUnit and a custom implementation of
WebApplicationFactory<TEntryPoint>
. If I make calls to that through a wiremock proxy with "save mappings" turned on the proxying does indeed work but I don't see any mappings getting saved anywhere.If I run the same code and settings with a console app against the actual running API the mappings get saved to files just fine.
The test project would look something like this: https://github.com/dahlsailrunner/testing-examples/tree/main/01-simple-api/SimpleApi.Tests
But I would simply run the
Client
http requests through the proxy. Should this be possible? I just don't get any saved mappings.I can provide an actual project / tests if it seems like this should be possible and such an example would be helpful.
The text was updated successfully, but these errors were encountered: