Skip to content
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

Remove Moq dependency #5106

Closed

Conversation

ngruson
Copy link
Contributor

@ngruson ngruson commented Nov 30, 2023

Refactor unit tests in order to remove the Moq dependency.

Changes

Mocks of TextMapPropagator have been removed.
I've introduced a CustomTextMapPropagator to be able to inject arbitrary key value pairs in the context of a unit test.
@vishweshbankwar : can you agree with this approach?

The dependency to the Moq package has been removed from all the test projects.
Mocking is now done using NSubstitute where needed.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@ngruson ngruson requested a review from a team November 30, 2023 20:36
@ngruson
Copy link
Contributor Author

ngruson commented Nov 30, 2023

Another option could be to use NSubstitute instead of Moq but I saw open-telemetry/opentelemetry-dotnet-instrumentation#2816 only after I did my changes.

Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Merging #5106 (c48a0c9) into main (f592dcf) will increase coverage by 0.07%.
Report is 1 commits behind head on main.
The diff coverage is n/a.

❗ Current head c48a0c9 differs from pull request most recent head d1cdc67. Consider uploading reports for the commit d1cdc67 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5106      +/-   ##
==========================================
+ Coverage   83.10%   83.17%   +0.07%     
==========================================
  Files         296      296              
  Lines       12318    12318              
==========================================
+ Hits        10237    10246       +9     
+ Misses       2081     2072       -9     
Flag Coverage Δ
unittests 83.17% <ø> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 7 files with indirect coverage changes

@vishweshbankwar
Copy link
Member

Another option could be to use NSubstitute instead of Moq but I saw open-telemetry/opentelemetry-dotnet-instrumentation#2816 only after I did my changes.

The approach you have looks good to me. We should avoid any additional dependency. (And in this case we can).

@ngruson ngruson changed the title Remove Moq dependency from OpenTelemetry.Instrumentation.Http.Tests Remove Moq dependency Dec 1, 2023
@ngruson
Copy link
Contributor Author

ngruson commented Dec 1, 2023

@vishweshbankwar : To remove the dependency to NSubstitute, more work needs to be done.
It probably involves adding implementations of classes that are now mocked.
Do you want me to try that or in a different PR?

@vishweshbankwar
Copy link
Member

@vishweshbankwar : To remove the dependency to NSubstitute, more work needs to be done. It probably involves adding implementations of classes that are now mocked. Do you want me to try that or in a different PR?

@ngruson We would like to avoid dependency on both NSubstitute and Mock. I'd suggest to tackle this one project at a time. For the current PR, lets scope this to Http one (as you had earlier) and move on to others in separate PRs. Does that sound ok?

@Yun-Ting
Copy link
Contributor

Yun-Ting commented Dec 1, 2023

FYI - this PR is related to this issue: #4758 (comment)

@utpilla
Copy link
Contributor

utpilla commented Dec 1, 2023

@ngruson We would like to avoid dependency on both NSubstitute and Mock. I'd suggest to tackle this one project at a time. For the current PR, lets scope this to Http one (as you had earlier) and move on to others in separate PRs.

💯

@ngruson ngruson closed this Dec 2, 2023
@ngruson ngruson deleted the remove-mock-textmappropagator branch December 6, 2023 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants