Removed 2 unnecessary stubbings in NetconfSessionTest.java#74
Open
ARUS2023 wants to merge 1 commit intoJuniper:masterfrom
Open
Removed 2 unnecessary stubbings in NetconfSessionTest.java#74ARUS2023 wants to merge 1 commit intoJuniper:masterfrom
ARUS2023 wants to merge 1 commit intoJuniper:masterfrom
Conversation
Contributor
|
#77 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In our analysis of the project, we observed that there are 8 tests
NetconfSessionTest.java.GIVEN_getCandidateConfig_WHEN_syntaxError_THEN_throwNetconfException,NetconfSessionTest.java.GIVEN_getRunningConfig_WHEN_syntaxError_THEN_throwNetconfException,NetconfSessionTest.java.GIVEN_createSession_WHEN_devicePromptWithoutLF_THEN_correctResponse,NetconfSessionTest.java.GIVEN_executeRPC_WHEN_syntaxError_THEN_throwNetconfException,NetconfSessionTest.java.GIVEN_stringWithoutRPC_fixupRPC_THEN_returnStringWrappedWithRPCTags,NetconfSessionTest.java.GIVEN_stringWithRPCTags_fixupRPC_THEN_returnWrappedString,NetconfSessionTest.java.GIVEN_stringWithTag_fixupRPC_THEN_returnWrappedString,and
NetconfSessionTest.java.GIVEN_nullString_WHEN_fixupRPC_THEN_throwException in NetconfSessionTest.javathat did not execute two stubbings in the setUp method causing them to be unnecessary.
There are also 7 tests:
NetconfSessionTest.java.loadXmlConfigurationWillFailIfResponseIsOkWithErrors,NetconfSessionTest.java.loadXmlConfigurationWillFailIfResponseIsNotOk,NetconfSessionTest.java.loadXmlConfigurationWillSucceedIfResponseIsOk,NetconfSessionTest.java.loadTextConfigurationWillFailIfResponseIsOkWithErrors,NetconfSessionTest.java.loadTextConfigurationWillFailIfResponseIsNotOk,NetconfSessionTest.java.loadTextConfigurationWillSucceedIfResponseIsOk,and
NetconfSessionTest.java.WHEN_instantiated_THEN_fetchHelloFromServer,that did not execute the stubbing
when(mockChannel.getInputStream()).thenReturn(inPipe)in the setUp method causing it to be unnecessary.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.