You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
note: this is a copy of an issue I've written at the old sonar groovy plugin. As it is stalled and my company migrated to this one, I just copied the text here. I guess the rule names are the same. If not, pls notice me so that I can update the description: pmayweg/sonar-groovy#89
We use the plugin mainly for our tests which are written in the awesome spock framework.
However, we noticed that at least three rules are applied to the test method name that don't make any sense in the context of a test method:
Here is some sample code that produces those issues
@SpringBootTestclassEndpointHealthCheckIntegrationTestextendsSpecification {
@AutowiredprivateEndpointHealthCheck healthCheck
def"endpoint is up and running"() {
when: 'health is queried'Health health = healthCheck.health().block()
then: 'status should be up'
health.status ==Status.UP
}
}
I resolve those issues as false positives and have to do it for every test method which is kinda annoying. On a side note, the def setup() and def tearDown() methods from Spock produce the NoDef-Rule violation as well, but they are much less annoying, as they are only rarely necessary (as opposed to a test class with usually 5-10 tests).
the convention for spock test methods is to use def and write a meaningful name (as GString) instead of a JUnit-style identifier
the JUnit rule is applied to this kind of tests (I guess because Spock uses JUnit in the background). It clearly can't identify the method as a test and tells me that all methods but tests should not be public.
The text was updated successfully, but these errors were encountered:
enolive
changed the title
Plugin produces 3 false positive in Spock Tests
Plugin produces 3 false positive for each test method in Spock Tests
Dec 3, 2019
note: this is a copy of an issue I've written at the old sonar groovy plugin. As it is stalled and my company migrated to this one, I just copied the text here. I guess the rule names are the same. If not, pls notice me so that I can update the description: pmayweg/sonar-groovy#89
We use the plugin mainly for our tests which are written in the awesome spock framework.
However, we noticed that at least three rules are applied to the test method name that don't make any sense in the context of a test method:
Here is some sample code that produces those issues
I resolve those issues as false positives and have to do it for every test method which is kinda annoying. On a side note, the
def setup()
anddef tearDown()
methods from Spock produce the NoDef-Rule violation as well, but they are much less annoying, as they are only rarely necessary (as opposed to a test class with usually 5-10 tests).def
and write a meaningful name (as GString) instead of a JUnit-style identifierThe text was updated successfully, but these errors were encountered: