Skip to content

Conversation

@ARUS2023
Copy link
Contributor

…oTest.java

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 ChangesSinceLastUnstableBuildMacroTest.createBuild are created but are only executed by some of the method calls in the test ChangesSinceLastUnstableBuildMacroTest.testGetContent_shouldGetPreviousBuildsThatArentUnstable_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. 4 unnecessary stubbings which stubbed getResult method, getChangeSet method, getChangeSets method, and getNumber method in ChangesSinceLastUnstableBuildMacroTest.createBuild are created but are not executed by the test ChangesSinceLastUnstableBuildMacroTest.testGetContent_shouldGetPreviousBuildsThatArentUnstable_HUDSON3519, 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. 2 unnecessary stubbings which stubbed getResult method, getChangeSet method in ChangesSinceLastUnstableBuildMacroTest.createBuildWithAffectedFiles are created but are are only executed by some of the method calls in 8 tests: ChangesSinceLastUnstableBuildMacroTest.testGetContent_shouldGetPreviousBuildFailures, ChangesSinceLastUnstableBuildMacroTest.testGetContent_whenReverseOrderIsTrueShouldReverseOrderOfChanges, ChangesSinceLastUnstableBuildMacroTest.testGetContent_shouldGetPreviousBuildsThatArentUnstable_HUDSON3519, ChangesSinceLastUnstableBuildMacroTest.testShouldPrintDate,
    ChangesSinceLastUnstableBuildMacroTest.testShouldPrintRevision, ChangesSinceLastUnstableBuildMacroTest.testShouldPrintPath,
    ChangesSinceLastUnstableBuildMacroTest.testWhenShowPathsIsTrueShouldPrintPath, ChangesSinceLastUnstableBuildMacroTest.testRegexReplace; We duplicated the createBuild method, removed the unnecessary stubbings, named it createBuild4, and applied the new method to the method call which does not execute the stubbings in the test.

  4. 1 unnecessary stubbings which stubbed getResult method, getChangeSet method in ChangesSinceLastUnstableBuildMacroTest.createBuildWithNoChanges are created but are never executed. We removed it.

  5. 1 unnecessary stubbing which stubbed iterator method in ChangesSinceLastUnstableBuildMacroTest.createChangeLog is created but is only executed by some specific method calls in the test ChangesSinceLastUnstableBuildMacroTest.testGetContent_shouldGetPreviousBuildsThatArentUnstable_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. We removed it.

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

  7. 3 unnecessary stubbings in the test 'ChangesSinceLastUnstableBuildMacroTest.testGetContent_shouldGetPreviousBuildsThatArentUnstable_HUDSON3519' are created but are never executed. We removed them.

  8. 1 unnecessary stubbing in the test 'ChangesSinceLastUnstableBuildMacroTest. whenReverseOrderIsTrueShouldReverseOrderOfChanges' is created but is 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.

Copy link
Member

@slide slide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign the commits

@ARUS2023 ARUS2023 force-pushed the remove-unnecessary-stubbings-3 branch from 9fb5db9 to 59d0778 Compare October 1, 2023 17:17
@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