Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin produces 3 false positives in Spock Tests for every test method #89

Open
enolive opened this issue Jun 12, 2019 · 0 comments
Open

Comments

@enolive
Copy link

enolive commented Jun 12, 2019

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:

  • grvy:org.codenarc.rule.convention.NoDefRule
  • grvy:org.codenarc.rule.naming.MethodNameRule.fixed
  • grvy:org.codenarc.rule.junit.JUnitPublicNonTestMethodRule

Here is some sample code that produces those issues

@SpringBootTest
class EndpointHealthCheckIntegrationTest extends Specification {
  @Autowired
  private EndpointHealthCheck 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.

  • 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.
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

No branches or pull requests

1 participant