Skip to content

Conversation

@ARUS2023
Copy link
Contributor

Testing done

### Submitter checklist
- [x] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [x] Ensure that the pull request title represents the desired changelog entry
- [x] Please describe what you did
- [ ] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream changes
- [ ] Ensure you have provided tests - that demonstrates feature works or fixes the issue

In our analysis of the project, we observed that

  1. 3 unnecessary stubbings which stubbed getChangeSet method, getChangeSets method, and getNumber method in ChangesSinceLastSuccessfulBuildMacroTest.createBuild are created but are only executed by some of the method calls in the test ChangesSinceLastSuccessfulBuildMacroTest.testGetContent_shouldGetPreviousBuildsThatArentSuccessful_HUDSON3519. We duplicated the createBuild method, removed the unnecessary stubbings, named it createBuild2, and applied the new method to the method call which does not execute the stubbings in the test.

  2. 2 unnecessary stubbings which stubbed getResult method, getChangeSet method in ChangesSinceLastSuccessfulBuildMacroTest.createBuildWithAffectedFiles are are only executed by some of the method calls in 8 tests: ChangesSinceLastSuccessfulBuildMacroTest.testGetContent_shouldGetPreviousBuildFailures, ChangesSinceLastSuccessfulBuildMacroTest.testGetContent_whenReverseOrderIsTrueShouldReverseOrderOfChanges, ChangesSinceLastSuccessfulBuildMacroTest.testGetContent_shouldGetPreviousBuildsThatArentSuccessful_HUDSON3519, ChangesSinceLastSuccessfulBuildMacroTest.testShouldPrintDate,
    ChangesSinceLastSuccessfulBuildMacroTest.testShouldPrintRevision, ChangesSinceLastSuccessfulBuildMacroTest.testShouldPrintPath,
    ChangesSinceLastSuccessfulBuildMacroTest.testWhenShowPathsIsTrueShouldPrintPath, ChangesSinceLastSuccessfulBuildMacroTest.testRegexReplace;
    We duplicated the createBuild method, removed the unnecessary stubbings, named it createBuild3, and applied the new method to the method call which does not execute the stubbings in the test.

  3. 1 unnecessary stubbing which stubbed getResult method in ChangesSinceLastSuccessfulBuildMacroTest.createBuildWithNoChangeSets is created but is never executed. We removed it.

  4. 2 unnecessary stubbings which stubbed getResult method, getChangeSet method in ChangesSinceLastSuccessfulBuildMacroTest.createBuildWithNoChanges are created but are never executed. WE removed them

  5. 1 unnecessary stubbing which stubbed iterator method in ChangesSinceLastSuccessfulBuildMacroTest.createChangeLog is created but is only executed by some of the method calls in the test ChangesSinceLastSuccessfulBuildMacroTest.testGetContent_shouldGetPreviousBuildsThatArentSuccessful_HUDSON3519.We duplicated the method, removed the unnecessary stubbings from the new duplicated method, named it createChangeLog2, and applied to the specific method call that doesn't execute the stubbing.

  6. 1 unnecessary stubbing which stubbed iterator method in ChangesSinceLastSuccessfulBuildMacroTest.createBuildWithAffectedFiles.createEmptyChangeLog is created but is never executed. We removed it.

  7. 1 unnecessary stubbing in the test 'ChangesSinceLastSuccessfulBuildMacroTest.testGetContent_shouldGetPreviousBuildsThatArentSuccessful_HUDSON3519' is created but never executed. We removed it.

  8. 1 unnecessary stubbing in the test 'ChangesSinceLastSuccessfulBuildMacroTest. testGetContent_whenReverseOrderIsTrueShouldReverseOrderOfChanges' is created but never executed. We removed it.

Unnecessary stubbings are stubbed method calls that were never realized during test execution. Mockito recommends to remove unnecessary stubbings (https://www.javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/exceptions/misusing/UnnecessaryStubbingException.html).

We propose below a solution to remove the unnecessary stubbings.

@slide
Copy link
Member

slide commented Sep 28, 2023

Please sign the commits

@ARUS2023 ARUS2023 force-pushed the remove-unnecessary-stubbings-2 branch from 9883711 to 977b282 Compare October 1, 2023 17:16
@ARUS2023
Copy link
Contributor Author

ARUS2023 commented Oct 2, 2023

Please sign the commits

Hello, the commit is signed.

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.

2 participants