#440 Run as JUnit test

open
nobody
5
2012-10-10
2006-11-06
Erik van Oosten
No

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

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

Discussion

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

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

     
  • Logged In: YES
    user_id=427006

    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
    user_id=746148

    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
    user_id=427006

    Yes, indeed.
    Thanks :)

     
  • Logged In: YES
    user_id=746148

    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
    2006-11-09

    Logged In: YES
    user_id=401384

    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
    2006-11-10

    Logged In: YES
    user_id=218824

    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
    user_id=427006

    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
    2007-03-24

    Logged In: YES
    user_id=43354
    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)