Use test host in unit tests#5040
Conversation
Build examples separately
|
|
|
@ngruson - Thank you for taking this. I have not used
Sdk.CreateMeterProviderBuilder()
.AddAspNetCoreInstrumentation()
.Build();In your test assert on collector is independent of assert on exported Items cc: @JamesNK |
|
regarding : https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/InProcServerTests.cs: We should delete this file as the test was added just for e.g. purpose. You could send a separate PR to remove that one. |
|
Other files that could be refactored to use the test host:
|
@ngruson Yes, it would be great if you could do that refactor. We don't need to refactor the Benchmarks one for now. BasicTests already uses WebApplicationFactory in most of the tests, we need to refactor the ones not using it like this one
It should be possible. May be try that in separate PR than |
…ngruson/opentelemetry-dotnet into 4976-improve-net8-metrics-tests
…into 4976-improve-net8-metrics-tests
…ngruson/opentelemetry-dotnet into 4976-improve-net8-metrics-tests
|
@vishweshbankwar : |
…ngruson/opentelemetry-dotnet into 4976-improve-net8-metrics-tests
…vedForExceptionsHandledInMiddleware
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs
Outdated
Show resolved
Hide resolved
vishweshbankwar
left a comment
There was a problem hiding this comment.
LGTM: Thanks @ngruson! Please clean up the PR description as well and describe the actual changes.
Just updated the PR description, is it sufficient? |
Correct, changelog updates are not done for unit test changes. |
Fixes issue #4976
Changes
@JamesNK gave some recommendations about the usage of
WebApplicationFactory.As much as possible, we have implemented that.
Some test cases require a
KestrelServerimplementation for Kestrel metrics to be emitted.In those cases, a
WebApplicationinstance is instantiated to run the unit test against.Previously, the hardcoded port number 5000 was used to run the host.
The port number is now made variable to isolate the unit test as much as possible.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes