-
Notifications
You must be signed in to change notification settings - Fork 773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use test host in unit tests #5040
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 : |
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
Outdated
Show resolved
Hide resolved
…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
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
KestrelServer
implementation for Kestrel metrics to be emitted.In those cases, a
WebApplication
instance 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.md
files updated for non-trivial changes