Skip to content

Conversation

@ARUS2023
Copy link

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.java
that 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.

@peterjhill
Copy link
Contributor

#77
covers all these I think

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