Skip to content

Replace live HTTP calls in integration tests with a mock HTTP server #33

Description

@tw4

Summary

Several tests in the test suite make real HTTP requests to external services like jsonplaceholder.typicode.com and fakestoreapi.com. This makes the tests unreliable (flaky) in CI environments and when running offline.

Problems

  • Tests fail if the external service is down or rate-limits the CI runner
  • Test execution is slow due to network latency
  • Not suitable for deterministic, offline test runs

Affected Test Files

  • StaticMethodsTests.cs
  • NexarTest.cs
  • ContentTypeTests.cs
  • RetryMechanismTests.cs

Proposed Solution

Replace external HTTP calls with a local mock HTTP server using Microsoft.AspNetCore.TestHost or a library like WireMock.Net.

// Example with WireMock.Net
var server = WireMockServer.Start();
server.Given(Request.Create().WithPath("/posts/1").UsingGet())
      .RespondWith(Response.Create().WithStatusCode(200).WithBodyAsJson(new { id = 1 }));

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtestingRelated to tests and test coverage

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions