Re: Test Custom Checks with JUnit
JMiddendorf <[email protected]> Thu, 1 Apr 2010 07:07:29 -0700 (PDT)
| Newsgroups | gmane.comp.java.audit.checkstyle.user |
|---|---|
| Message-ID | <[email protected]> |
Finally I could fix the problem.
It was an IDE problem. After I integrate the checkstyle sourcecode in a new
eclipse project, my mistake was to add my checks per drag&drop over the IDE
interface. Eclipse didn’t copied the source files to the correct
src/checkstyle folder, it just showed a link to the file. After I copied my
files to the correct folder the test and build process succeeds.
JMiddendorf wrote:
>
> Hello guys,
>
> In my bachelor-thesis I write some custom checks to check if a class can
> be just known/used by it’s interface (Objects have to be created with a
> factory) and is using composition instead of inheritance (see Java Objects
> by Interfaces http://www-home.fh-konstanz.de/~haase/joi/joi.pdf).
> Now I want to test them with JUnit and integrate them in your sourcecode
> to be able to contribute the checks.
>
> So I started an eclipse java project, where I integrate your source code
> and add a package (to make it simple I named them in your style)
> com.puppycrawl.tools.checkstyle.checks.joi to the checkstyle src folder
> containing my custom checks.
> In the test src folder I add a package with the same containing the
> testcases, and the same for the testinput folder.
>
> Now finally comes my problem: When I want to run the ant file build.xml I
> always get this error message:
> compile.tests:
> [depend] Deleted 1 out of date files in 0 seconds
> [javac] Compiling 1 source file to
> E:\workspace\checkstyle-v5\target\tests
> [javac]
> E:\workspace\checkstyle-v5\src\tests\com\puppycrawl\tools\checkstyle\checks\joi\JOICreationalPatternCheckTest.java:15:
> cannot find symbol
> [javac] symbol : class JOICreationalPatternCheck
> [javac] location: class
> com.puppycrawl.tools.checkstyle.checks.joi.JOICreationalPatternCheckTest
> [javac] createCheckConfig(JOICreationalPatternCheck.class);
> [javac] ^
> [javac] 1 error
>
> BUILD FAILED
>
> When I delete my Testscases the build process and tests succeeds.
> My test case (snipped) locks like this:
>
> package com.puppycrawl.tools.checkstyle.checks.joi;
>
> import java.io.File;
>
> import org.junit.Test;
>
> import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
> import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
>
> public class JOICreationalPatternCheckTest extends BaseCheckTestSupport
> {
> @Test
> public void testPrivateConstructor() throws Exception {
> DefaultConfiguration checkConfig =
> createCheckConfig(JOICreationalPatternCheck.class);
>
> String[] expected = {
> "2:component constructor private"
> };
>
> verify(checkConfig, getPath("joi" + File.separator +
> "Komponente.java"), expected);
> }
> }
>
> Can you help me?
> Do I have to do some more configuration?
> I already added my Checks to checkstyle_check.xml and the package to the
> checkstyle_package.xml.
> Thank you very much!
> Best regards
> Jonas Middendorf (Germany)
>
>
--
View this message in context: http://old.nabble.com/Test-Custom-Checks-with-JUnit-tp28079951p28107799.html
Sent from the CheckStyle - User mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Checkstyle-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user