Using Application Insights with Unit Tests?

前端 未结 5 2113
时光取名叫无心
时光取名叫无心 2020-12-14 08:15

I have an MVC web app, and I\'m using Simple Injector for DI. Almost all my code is covered by unit tests. However, now that I\'ve added some telemetry calls in some contr

5条回答
  •  借酒劲吻你
    2020-12-14 08:24

    If you don't want to go down the abstraction / wrapper path. In your tests you could simply direct the AppInsights endpoint to a mock lightweight http server (which is trivial in ASP.NET Core).

    appInsightsSettings.json

        "ApplicationInsights": {
        "Endpoint": "http://localhost:8888/v2/track"
    }
    

    How to set up "TestServer" in ASP.NET Core http://josephwoodward.co.uk/2016/07/integration-testing-asp-net-core-middleware

提交回复
热议问题