Skip to content
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

Too much recorded? #673

Open
AdiuTankT72 opened this issue Dec 13, 2024 · 0 comments
Open

Too much recorded? #673

AdiuTankT72 opened this issue Dec 13, 2024 · 0 comments

Comments

@AdiuTankT72
Copy link

AdiuTankT72 commented Dec 13, 2024

I have a .NET core tests of API. Inside my API I am doing many different other http calls. I wanted to verify the response from my API with Verify.Http and it works if I run a single test. But If I am running all tests then Verify somehow records also those "internal" http calls done by my API instead of the response given to my test by my API....
on the left - when I run multiple tests. On the right - when running single test.
image
...
image

I am using MSTests.
My setup:

[TestClass]
[UsesVerify]
public partial class VerifyChecksTests
{
    [TestMethod]
    public Task Run() => VerifyChecks.Run();

    [ModuleInitializer]
    public static void Initialize()
    {
        VerifyHttp.Initialize();
        Recording.Start();
    }
}
public abstract class IntegrationTestsBase
{
    protected readonly VerifySettings _verifySettings = new VerifySettings();

    protected readonly HttpClient _httpClient;
    protected IntegrationTestsBase()
    {
        _verifySettings.UseDirectory("Infrastructure/VerifySnapshots");
var app = new WebApplicationFactory<Program>().WithWebHostBuilder(builder =>
{
....
_httpClient = app.CreateClient();

Example test:

[TestMethod]
public async Task GetIndexesFields_ShouldReturnAllFields()
{
    //Act
    HttpResponseMessage responseMessage = await _httpClient.GetAsync("/api/v1/indexes/0");

    //Assert
    await Verify(responseMessage, _verifySettings);
}

Am I doing something wrong or is it a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant