You didn't post the code for your API so that we can confirm you're returning a 200 from the request. Have you verified via curl, Postman, Powershell or even the browser that the response is actually 200?
.NET Core C# web API integration testing an inmemory database

Soluble Snake
1
Reputation point
I'm currently trying to create an integration test for my .NET Core Web API. I'm following the advice here: https://timdeschryver.dev/blog/how-to-test-your-csharp-web-api
When I run my test to check the HttpStatusCode 'Should' 'Be' ok, the test is failing BUT the test does pass if I use the '/weatherforecast' example that comes with the .NET Core Web API template. If I use my project, the test fails. Is this because I have no values created in the DB when I start the app? How do I create those values? The code for my test is below:
[Fact]
public async Task Get_Should_Retrieve_Score()
{
var response = await Client.GetAsync("/diceroll");
response.StatusCode.Should().Be(HttpStatusCode.OK);
//var DiceRoll = JsonConvert.DeserializeObject<DiceRoll[]>(await response.Content.ReadAsStringAsync());
//forecast.Should().HaveCount(0);
}
Thanks for any help anyone can provide!