Test Custom Checks with JUnit
JMiddendorf <[email protected]> Wed, 31 Mar 2010 07:10:59 -0700 (PDT)
| Newsgroups | gmane.comp.java.audit.checkstyle.user |
|---|---|
| Message-ID | <[email protected]> |
Hello guys,
In my bachelor-thesis 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)
-Update---
I have treid a little bit more. When write
DefaultConfiguration checkConfig = new DefaultConfiguration
("JOICreationalPatternCheck");
everythink works fine and also when I write
DefaultConfiguration checkConfig
createCheckConfig(Class.forName("JOICreationalPatternCheck");
it works to.
But I still would like to to it the same way you do.
--
View this message in context: http://old.nabble.com/Test-Custom-Checks-with-JUnit-tp28079951p28079951.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