#440 Run as JUnit test

Future
closed
nobody
5
2016-02-28
2006-11-06
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

  • Oleg Sukhodolsky

    Logged In: YES
    user_id=746148

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

     
  • Erik van Oosten

    Erik van Oosten - 2006-11-07

    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.

     
  • Oleg Sukhodolsky

    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 :)

     
  • Erik van Oosten

    Erik van Oosten - 2006-11-07

    Logged In: YES
    user_id=427006

    Yes, indeed.
    Thanks :)

     
  • Oleg Sukhodolsky

    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().

     
  • Erik van Oosten

    Erik van Oosten - 2006-11-10

    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.

     
  • Lars Kühne

    Lars Kühne - 2007-04-01

    Logged In: YES
    user_id=401384
    Originator: NO

    elmartinos, thanks for offering a contribution. I don't think anyone is actively working on this issue.
    Please attach your code here, preferably in patch format.

     
  • Martin Ankerl

    Martin Ankerl - 2007-04-01

    Logged In: YES
    user_id=43354
    Originator: NO

    Hi, I'd like to attach my code, but I don't know how so I've uploaded it to my website.

    I did not want to modified any checkstyle code, so I have just used the ant task and overwrote the logging method. I know this is a pretty ugly hook to use and there surely is something nicer, but this was the simplest way to implement it.

    For the usage have a look at the test.
    http://martin.ankerl.com/files/checkstyle-junit/CheckStyleTest.java

    And here is the code:
    http://martin.ankerl.com/files/checkstyle-junit/CheckStyle.java

    You need ant in your build path for this to work.

     
  • Lars Kühne

    Lars Kühne - 2007-04-03

    Logged In: YES
    user_id=401384
    Originator: NO

    Thanks for the contribution. If you are still interested in cleaning this up, the final solution would need to get rid of the Ant dependency. Probably you can also extract some common code from the Ant task and the command line interface Main class to your Checkstyle class and make those frontends use your Checkstyle class much like your usage demo does. Let us know if you hit any problem.

    BTW, you can attach files via the "Upload and attach files" form below the "comments" area, near the bottom of this page.

     
  • Roman Ivanov

    Roman Ivanov - 2016-02-28
    • status: open --> closed
    • Group: --> Future
     
  • Roman Ivanov

    Roman Ivanov - 2016-02-28

    I do not think that is reasonable at 2016 year, build systems are must have for all projects now. We have integration to all of them. Extra dependecies in test phase are unwanted.

    If smb is not agree please be welcome to mail-list for discussion.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks