Skip to content

Resolved mismatch stubbings in CompareCoverageActionTest.java #127

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ARMS2025
Copy link

I analyzed the test doubles (mocks) in the test code of the project. In my analysis of the project, I observed that

In tests postCoverageStatusToPullRequestAsComment, postResultAsStatusCheck, postResultAsSuccessfulStatusCheck, postResultAsFailedStatusCheck, keepBuildGreenAndLogErrorIfExceptionDuringGitHubAccess, postCoverageStatusToPullRequestAsCommentWithShieldIoIfPrivateJenkinsPublicGitHubTurnOn and postCoverageStatusToPullRequestAsCommentWithCustomJenkinsUrlIfConfigured,

  • The get method for the envVars object:
    i) is stubbed in the prepareEnvVars method
    ii) during test execution the method is actually called with argument "CHANGE_ID", but is not stubbed, resulting in a mismatch stubbing
    iii) during test execution the method is actually called with argument "CHANGE_URL", but is not stubbed, resulting in another mismatch stubbing

In general, a mismatched stubbing occurs when a method is stubbed with specific arguments in a test but later invoked with different arguments in the code. Mockito recommends addressing this type of issue (https://www.javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/exceptions/misusing/PotentialStubbingProblem.html).

I propose a solution below to resolve the mismatch stubbing. Happy to modify the pull request based on your feedback.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry (Not applicable)
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira (Not applicable)
  • Link to relevant pull requests, esp. upstream and downstream changes (Not applicable)
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed (Not applicable)

@ARMS2025 ARMS2025 requested a review from a team as a code owner May 15, 2025 16:42
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.

1 participant