JasperFx / alba

Easy integration testing for ASP.NET Core applications
https://jasperfx.github.io/alba
Apache License 2.0
407 stars 39 forks source link

Request not finished if body not read #73

Closed LodewijkSioen closed 4 years ago

LodewijkSioen commented 4 years ago

I'm using an xUnit collection fixture to setup Alba. In my test I have the following (pseudo) code:

using(ISession and Transaction) 
{
    Put Something in the database;
}

await System.Scenario(s => {
    s.Put.UpdateSomething.ToUrl("/api/");
    s.StatusCodeShouldBe(200);
});

using(ISession and transaction)
{
    Assert if Something has been updated
}

My assertion fails at this point. If I check what's in the database after the test has run, I see the updated values. I can make the test run if I read the body of the request before my assertion.

My guess is that the body of my request is only streamed if I actually read it. That means that the transaction (from middleware) around my api-call is still open when I do my assertions.

Is there an easy way to tell Alba to close the request when I'm not interested in the body?

LodewijkSioen commented 4 years ago

Nevermind, I just realised that this is an issue with my code 😄 Some client can also just listen to the statuscode and not bother with the body. They'll get a 200 but the transaction can still fail. I'll have to put my transactions elsewhere.