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

Fix multi-threaded environment variable mocking #46

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

ashleyfrieze
Copy link
Member

@ashleyfrieze ashleyfrieze commented Jun 29, 2022

Owing to a limitation of Mockito's mockStatic function, which deliberately limits static mocking to the calling thread, the environment variable mocking has not worked in any other worker threads involved in the test.

This was reported in #45

By switching from using Mockito to using ByteBuddy and mocking the ProcessEnvironment closer to the bytecode, we can overcome this constraint.

@codecov-commenter
Copy link

codecov-commenter commented Jun 29, 2022

Codecov Report

Patch coverage: 28.57% and project coverage change: -3.56% ⚠️

Comparison is base (3b4ea68) 84.76% compared to head (7c81ec9) 81.20%.

❗ Current head 7c81ec9 differs from pull request most recent head 3af3bb4. Consider uploading reports for the commit 3af3bb4 to get more accurate results

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #46      +/-   ##
============================================
- Coverage     84.76%   81.20%   -3.56%     
+ Complexity      347      326      -21     
============================================
  Files            46       47       +1     
  Lines           755      761       +6     
  Branches         40       40              
============================================
- Hits            640      618      -22     
- Misses           99      129      +30     
+ Partials         16       14       -2     
Files Changed Coverage Δ
...re/systemstubs/security/NoExitSecurityManager.java 94.94% <ø> (-0.55%) ⬇️
...ere/systemstubs/stream/input/ThrowAtEndStream.java 81.57% <ø> (ø)
...mstubs/internal/ProcessEnvironmentInterceptor.java 0.00% <0.00%> (ø)
...emstubs/environment/EnvironmentVariableMocker.java 93.02% <100.00%> (+40.39%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ashleyfrieze ashleyfrieze marked this pull request as ready for review September 6, 2023 08:33
@ashleyfrieze ashleyfrieze merged commit b70b843 into main Sep 6, 2023
1 of 2 checks passed
@ashleyfrieze ashleyfrieze deleted the threads-example branch September 6, 2023 08:33
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.

None yet

2 participants