I have this JUnit test:
@Test
public void testExecuteReverseAcknowledgement(@Mocked final MessageDAO messageDAO) {
//...
classUnderTest.execute(messageContext, actionContext);
Verifications verifications = new Verifications() {{
messageDAO.setAcknowledgement("APC");
}};
}
It works as needed, assertions are done in the Verifications block (http://jmockit.org/tutorial/Mocking.html#model)
Unfortunately, IntelliJ IDEA produces a warning: "Unit test method 'testExecuteReverseAcknowledgement()' contains no assertions".
It is possible to configure this inspection and specify classes with methods that Intellij will consider as assertions:
But I don't seem to be able to specify the mockit.Verifications() Constructor there. I've tried "mockit.Verifications" as class name and ".*", "new", "()" as method names.
My question is, how can I specify Verifications class as assertion so that IntelliJ does not produce that warning?
I guess, unfortunately, IDEA searches any method other than the constructor.
I've checked sources and made a debug IDEA. Pattern ".*" is correct, but this code does not execute for a constructor.
You can see the code here: https://github.com/JetBrains/intellij-community/blob/master/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/TestMethodWithoutAssertionInspectionBase.java
It's a good opportunity to make a feature request :)