Author: tchemit Date: 2009-09-06 22:27:59 +0200 (Sun, 06 Sep 2009) New Revision: 568 Modified: trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java Log: automatic tests discovering Modified: trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java =================================================================== --- trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-06 13:31:48 UTC (rev 567) +++ trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-06 20:27:59 UTC (rev 568) @@ -32,6 +32,8 @@ import java.util.List; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusTestCase; +import org.junit.Ignore; +import org.junit.Test; import org.nuiton.AbstractPlugin; /** @@ -70,6 +72,29 @@ testDir = new File(f, rep); System.out.println("test dir : " + testDir); + if (testNames.length == 0) { + + // auto looking up for tests names, methods which respect + // with @PluginConfig + // with @Test + // without @Ignore + + List<String> testNamesList = new ArrayList<String>(); + for (Method m : klass.getMethods()) { + PluginConfig annotation = m.getAnnotation(PluginConfig.class); + if (annotation != null) { + Test t = m.getAnnotation(Test.class); + if (t != null) { + Ignore i = m.getAnnotation(Ignore.class); + if (i==null) { + testNamesList.add(m.getName()); + } + } + } + } + testNames = testNamesList.toArray(new String[testNamesList.size()]); + } + for (String testName : testNames) { Method m = klass.getMethod(testName); if (m == null) {