[JAVA] S2699 Tests should include assertions - FP when use Mockito.verifyZeroInteractions

146 views
Skip to first unread message

Adam Gabryś

unread,
Apr 24, 2016, 12:48:06 PM4/24/16
to SonarQube
Hello,
I read in other topic
(https://groups.google.com/forum/#!msg/sonarqube/ObGF7lPGtRo/z2-AJZczBwAJ)
that Java plugin supports Mockito library. I created a test which
executes Mockito.verifyZeroInteractions inside, but SonarQube found
S2699 issue. Is this a bug in rule?

Example:

@Test
public void test() { // S2699 on this line: Add at least one assertion
to this test case
final Processor processor = new DoNothingProcessor();
final Argument argument = Mockito.mock(Argument .class)
// DoNothingProcessor should not change argument state
processor.prepare(argument);
Mockito.verifyZeroInteractions(argument);
}

Java plugin: 3.13.1

Regads,
Adam Gabryś

Michael Gumowski

unread,
Apr 27, 2016, 3:28:57 AM4/27/16
to Adam Gabryś, SonarQube
Hey Adam,

Regarding Mockito, the rule is currently only looking for Mockito.verifyNoMoreInteractions(). I created the following ticket to also handle Mockito.verifyZeroInteractions()https://jira.sonarsource.com/browse/SONARJAVA-1658

I also checked for other usages of Mockito which should be handled, and note that completeness of Mockito.verify() is already handled by squid:S2970.

Regards,

Michael GUMOWSKI | SonarSource
Software Developer @ Language Team
http://sonarsource.com



--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/BLU436-SMTP40FC3FC4B83BDA74A464D398610%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages