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. 4 unnecessary stubbings which stubbed getResult method, getChangeSet method, getChangeSets method, and getNumber method in ChangesSinceLastBuildMacroTest.createBuild are created but are only executed by some of the method calls in the test ChangesSinceLastBuildMacroTest.testShouldGetChangesForLatestBuildEvenWhenPreviousBuildsExist.
    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. 3 unnecessary stubbings which stubbed getResult method, getChangeSet method, and getNumber method in ChangesSinceLastBuildMacroTest.createBuildWithAffectedFiles are created but are never executed. We removed them from the test.

  3. 3 unnecessary stubbings which stubbed getResult method, getChangeSet method, and getNumber method in ChangesSinceLastBuildMacroTest.createBuildWithNoChanges are created but are never executed. We removed them from the test.

  4. 1 unnecessary stubbing which stubbed iterator method in ChangesSinceLastBuildMacroTest.createBuildWithAffectedFiles.createChangeLog is created but is never executed by the test 'ChangesSinceLastBuildMacroTest.testShouldGetChangesForLatestBuildEvenWhenPreviousBuildsExist', 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.

  5. 1 unnecessary stubbing which stubbed the iterator method in ChangesSinceLastBuildMacroTest.createBuildWithAffectedFiles.createEmptyChangeLog is created but is never executed. We removed it.

  6. 2 unnecessary stubbings in the test ChangesSinceLastBuildMacroTest.testShouldGetChangesForLatestBuildEvenWhenPreviousBuildsExist are created but never executed. We removed them.

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-1 branch from 4b82ac5 to 75d56d4 Compare October 1, 2023 17:14
@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