#440 Run as JUnit test

Erik van Oosten

It would be convenient to be able to run checkstyle as
a JUnit test suite.

Here are some advantages:
- enables you to run checkstyle in any environment that
allows you to run JUnit tests (which is a lot!)

  • single location for quality reports

  • less build scripts syntax to learn

- the unit test needs to be setup to gets its configuration


1 2 > >> (Page 1 of 2)
  • Logged In: YES

    Could you please be more specific what exactly you consider
    as unnecessary complexity?

  • Logged In: YES

    I am not talking about 'unnecessary complex'. I am talking
    about another option of running the checkstyle rules.

    What I would like to see is a JUnit test suit that fails
    when a checkstyle rule is violated. Ideally, it will showone
    failure per violation.

    The idea is that many people already have a JUnit test
    environment in place. By re-using this environment, these
    people do not need to find and configure a checkstyle runner
    for that environment. In addition, I think it is very nice
    to have the output from regular JUnit tests aggregated with
    the checkstyle results.

  • Logged In: YES

    So, you want us to provide one more runner class which will
    represent JUnit's test suite.
    I'd say it is rather interesting idea :)

  • Logged In: YES

    Yes, indeed.
    Thanks :)

  • Logged In: YES

    One question came to my mind today: how do you suggest to
    pass configuration parameters (such as config file, files to
    check etc) to Checkstyle?

  • Lars Kühne
    Lars Kühne

    Logged In: YES

    Does that mean this request boils down to providing a
    simpler API for programmatically running Checkstyle, e.g.
    without having to register listeners?

  • Oliver Burn
    Oliver Burn

    Logged In: YES

    I guess so - but I am not sure of the "bang for buck" in doing this.

    I support alternatively you could provide something similar to to the command line
    class that returned an error count, rather than calling System.exit().

  • Logged In: YES

    I thought about the configuration issue as well.
    The only really easy solution I can come up with is to
    require that the checkstyle config is located on the
    classpath and has a well known filename.

  • Martin Ankerl
    Martin Ankerl

    Logged In: YES
    Originator: NO

    Hi all, is there somebody working on this? For a project I work on I have written a wrapper for checkstyle (PMD and findbugs too) so that it executes as a unit test. It is quite a hack, but it works which is good enough for me. I can contribute code and work on a clean implementation with some guidance.

1 2 > >> (Page 1 of 2)