squid:S2699 (Tests should include assertions) and JMockit

161 views
Skip to first unread message

jka...@gmail.com

unread,
Oct 4, 2017, 10:34:23 AM10/4/17
to SonarQube
Good Morning,

I use JMockit as my mocking framework, and while most mock-enabled tests use assertions (AssertJ in my case), there are times when I use the JMockit StrictExpectations and various subclasses of the Verifications class to make assertions. Squid rule S2699 doesn't recognize these as assertions and flags the test method with a rule violation.  I don't want to disable the rule because I use it to help mentor junior developers and adding  @SuppressWarnings("squid:S2699") to thousands of methods is lot of work.

Can the JMockit assertions be added to S2699?

Regards,

Jim Kaib

Michael Gumowski

unread,
Oct 9, 2017, 12:23:18 PM10/9/17
to jka...@gmail.com, SonarQube
Hello Jim,

Indeed, JMockit is currently not supported. As we are not familiar with this framework, could you provide, as a starting point, some basic examples of compliant and non-compliant usages of JMockit StrictExepctations.

In the meantime, I created the following ticket, to be enriched with further examples: SONARJAVA-2517

Cheers,
Michael

--
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/d4f6f892-aba4-4832-8024-334e951cba26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Michael Gumowski | SonarSource
Software Developer, Language Team
https://www.sonarsource.com
Reply all
Reply to author
Forward
0 new messages