git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1523198 13f79535-47bb-0310-9956-ffa450edef68master
@@ -526,6 +526,18 @@ the name of the resulting class (without suffix). It defaults to <i>java-tmp-dir | |||||
<td valign="top">Only run test <a href="../properties.html#if+unless">if the named property is <b>not</b> set</a>.</td> | <td valign="top">Only run test <a href="../properties.html#if+unless">if the named property is <b>not</b> set</a>.</td> | ||||
<td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
</tr> | </tr> | ||||
<tr> | |||||
<td valign="top">skipNonTests</td> | |||||
<td valign="top">Do not pass any classes that do not contain JUnit tests to the test runner. | |||||
This prevents non tests from appearing as test errors in test results.<br /> | |||||
Tests are identified by looking for the <code>@Test</code> annotation on any methods in concrete classes | |||||
that don't extend <code>junit.framework.TestCase</code>, or for public/protected methods with | |||||
names starting with 'test' in concrete classes that extend <code>junit.framework.TestCase</code>. | |||||
Classes marked with the JUnit4 <code>org.junit.runner.RunWith</code> or | |||||
<code>org.junit.runner.Suite.SuiteClasses</code> annotations are also passed to JUnit for execution, | |||||
as is any class with a public/protected no-argument <code>suite</code> method.</td> | |||||
<td align="center" valign="top">No. Default is false.</td> | |||||
</tr> | |||||
</table> | </table> | ||||
<p>Tests can define their own formatters via nested | <p>Tests can define their own formatters via nested | ||||
@@ -604,6 +616,18 @@ supported.</p> | |||||
<td valign="top">Only run tests <a href="../properties.html#if+unless">if the named property is <strong>not</strong> set</a>.</td> | <td valign="top">Only run tests <a href="../properties.html#if+unless">if the named property is <strong>not</strong> set</a>.</td> | ||||
<td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
</tr> | </tr> | ||||
<tr> | |||||
<td valign="top">skipNonTests</td> | |||||
<td valign="top">Do not pass any classes that do not contain JUnit tests to the test runner. | |||||
This prevents non tests from appearing as test errors in test results.<br /> | |||||
Tests are identified by looking for the <code>@Test</code> annotation on any methods in concrete classes | |||||
that don't extend <code>junit.framework.TestCase</code>, or for public/protected methods with | |||||
names starting with 'test' in concrete classes that extend <code>junit.framework.TestCase</code>. | |||||
Classes marked with the JUnit4 <code>org.junit.runner.RunWith</code> or | |||||
<code>org.junit.runner.Suite.SuiteClasses</code> annotations are also passed to JUnit for execution, | |||||
as is any class with a public/protected no-argument <code>suite</code> method.</td> | |||||
<td align="center" valign="top">No. Default is false.</td> | |||||
</tr> | |||||
</table> | </table> | ||||
<p>Batchtests can define their own formatters via nested | <p>Batchtests can define their own formatters via nested | ||||
@@ -649,7 +673,7 @@ supported.</p> | |||||
<p>to your <code>junit</code> task.</p> | <p>to your <code>junit</code> task.</p> | ||||
<h3><a name="enabletestlistenerevents"><code>ant.junit.enabletestlistenerevents</a> | |||||
<h3><a name="enabletestlistenerevents"><code>ant.junit.enabletestlistenerevents</code></a> | |||||
magic property</h3> | magic property</h3> | ||||
<p><em>Since Ant 1.8.2</em> the <code>enableTestListenerEvents</code> | <p><em>Since Ant 1.8.2</em> the <code>enableTestListenerEvents</code> | ||||
@@ -292,6 +292,39 @@ | |||||
</junit> | </junit> | ||||
</target> | </target> | ||||
<!-- Skipping classes that are not tests --> | |||||
<target name="testNonTests"> | |||||
<mkdir dir="out"/> | |||||
<junit fork="true"> | |||||
<classpath refid="test"/> | |||||
<formatter type="xml"/> | |||||
<classpath refid="test"/> | |||||
<batchtest todir="out" skipNonTests="true"> | |||||
<fileset dir="../../../../tests/junit"> | |||||
<include name="org/example/junit/*Missed.java"/> | |||||
<!-- tests remove out-dir on tearDown --> | |||||
</fileset> | |||||
</batchtest> | |||||
</junit> | |||||
</target> | |||||
<!-- Not skipping classes that are not tests --> | |||||
<target name="testNonTestsRun"> | |||||
<mkdir dir="out"/> | |||||
<junit fork="true"> | |||||
<classpath refid="test"/> | |||||
<formatter type="xml"/> | |||||
<classpath refid="test"/> | |||||
<batchtest todir="out" skipNonTests="false"> | |||||
<fileset dir="../../../../tests/junit"> | |||||
<include name="org/example/junit/*Missed.java"/> | |||||
<!-- tests remove out-dir on tearDown --> | |||||
</fileset> | |||||
</batchtest> | |||||
</junit> | |||||
</target> | |||||
<target name="testTestMethods" > | <target name="testTestMethods" > | ||||
<property name="tmp.dir" value="out"/> | <property name="tmp.dir" value="out"/> | ||||
<echo file="${tmp.dir}/T1.java">public class T1 extends | <echo file="${tmp.dir}/T1.java">public class T1 extends | ||||
@@ -42,6 +42,7 @@ public abstract class BaseTest { | |||||
// CheckStyle:VisibilityModifier ON | // CheckStyle:VisibilityModifier ON | ||||
private Object ifCond, unlessCond; | private Object ifCond, unlessCond; | ||||
private boolean skipNonTests; | |||||
/** | /** | ||||
* Set the filtertrace attribute. | * Set the filtertrace attribute. | ||||
@@ -229,4 +230,12 @@ public abstract class BaseTest { | |||||
public void setErrorProperty(String errorProperty) { | public void setErrorProperty(String errorProperty) { | ||||
this.errorProperty = errorProperty; | this.errorProperty = errorProperty; | ||||
} | } | ||||
public void setSkipNonTests(boolean skipNonTests) { | |||||
this.skipNonTests = skipNonTests; | |||||
} | |||||
public boolean isSkipNonTests() { | |||||
return skipNonTests; | |||||
} | |||||
} | } |
@@ -191,6 +191,7 @@ public final class BatchTest extends BaseTest { | |||||
test.setTodir(this.destDir); | test.setTodir(this.destDir); | ||||
test.setFailureProperty(failureProperty); | test.setFailureProperty(failureProperty); | ||||
test.setErrorProperty(errorProperty); | test.setErrorProperty(errorProperty); | ||||
test.setSkipNonTests(isSkipNonTests()); | |||||
Enumeration list = this.formatters.elements(); | Enumeration list = this.formatters.elements(); | ||||
while (list.hasMoreElements()) { | while (list.hasMoreElements()) { | ||||
test.addFormatter((FormatterElement) list.nextElement()); | test.addFormatter((FormatterElement) list.nextElement()); | ||||
@@ -37,4 +37,5 @@ public class Constants { | |||||
static final String TESTSFILE = "testsfile="; | static final String TESTSFILE = "testsfile="; | ||||
static final String TERMINATED_SUCCESSFULLY = "terminated successfully"; | static final String TERMINATED_SUCCESSFULLY = "terminated successfully"; | ||||
static final String LOG_FAILED_TESTS="logfailedtests="; | static final String LOG_FAILED_TESTS="logfailedtests="; | ||||
static final String SKIP_NON_TESTS = "skipNonTests="; | |||||
} | } |
@@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs.optional.junit; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
import java.io.IOException; | |||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
import java.lang.reflect.Field; | import java.lang.reflect.Field; | ||||
@@ -310,11 +311,7 @@ public class FormatterElement { | |||||
JUnitTaskMirror.JUnitResultFormatterMirror r = | JUnitTaskMirror.JUnitResultFormatterMirror r = | ||||
(JUnitTaskMirror.JUnitResultFormatterMirror) o; | (JUnitTaskMirror.JUnitResultFormatterMirror) o; | ||||
if (useFile && outFile != null) { | if (useFile && outFile != null) { | ||||
try { | |||||
out = new BufferedOutputStream(new FileOutputStream(outFile)); | |||||
} catch (java.io.IOException e) { | |||||
throw new BuildException("Unable to open file " + outFile, e); | |||||
} | |||||
out = new DelayedFileOutputStream(outFile); | |||||
} | } | ||||
r.setOutput(out); | r.setOutput(out); | ||||
@@ -361,4 +358,44 @@ public class FormatterElement { | |||||
return new String[] {"plain", "xml", "brief", "failure"}; | return new String[] {"plain", "xml", "brief", "failure"}; | ||||
} | } | ||||
} | } | ||||
/** | |||||
* A standard FileOutputStream creates a file as soon as it's opened. This | |||||
* class delays the creation of the file until the first time a caller attempts | |||||
* to write to it so we don't end up with empty files if the listeners don't use | |||||
* them. | |||||
*/ | |||||
private static class DelayedFileOutputStream extends OutputStream { | |||||
private BufferedOutputStream outputStream; | |||||
private final File file; | |||||
public DelayedFileOutputStream(File file) { | |||||
this.file = file; | |||||
} | |||||
@Override | |||||
public void write(int b) throws IOException { | |||||
synchronized (this) { | |||||
if (outputStream == null) { | |||||
outputStream = new BufferedOutputStream(new FileOutputStream(file)); | |||||
} | |||||
} | |||||
outputStream.write(b); | |||||
} | |||||
@Override | |||||
public void flush() throws IOException { | |||||
if (outputStream != null) { | |||||
outputStream.flush(); | |||||
} | |||||
} | |||||
@Override | |||||
public void close() throws IOException { | |||||
if (outputStream != null) { | |||||
outputStream.close(); | |||||
} | |||||
} | |||||
} | |||||
} | } |
@@ -976,6 +976,7 @@ public class JUnitTask extends Task { | |||||
cmd.createArgument().setValue(Constants.TESTSFILE + casesFile); | cmd.createArgument().setValue(Constants.TESTSFILE + casesFile); | ||||
} | } | ||||
cmd.createArgument().setValue(Constants.SKIP_NON_TESTS + String.valueOf(test.isSkipNonTests())); | |||||
cmd.createArgument().setValue(Constants.FILTERTRACE + test.getFiltertrace()); | cmd.createArgument().setValue(Constants.FILTERTRACE + test.getFiltertrace()); | ||||
cmd.createArgument().setValue(Constants.HALT_ON_ERROR + test.getHaltonerror()); | cmd.createArgument().setValue(Constants.HALT_ON_ERROR + test.getHaltonerror()); | ||||
cmd.createArgument().setValue(Constants.HALT_ON_FAILURE | cmd.createArgument().setValue(Constants.HALT_ON_FAILURE | ||||
@@ -30,6 +30,7 @@ import java.io.PrintStream; | |||||
import java.io.StringReader; | import java.io.StringReader; | ||||
import java.io.StringWriter; | import java.io.StringWriter; | ||||
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
import java.lang.reflect.Modifier; | |||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import java.util.Hashtable; | import java.util.Hashtable; | ||||
import java.util.Properties; | import java.util.Properties; | ||||
@@ -37,6 +38,7 @@ import java.util.StringTokenizer; | |||||
import java.util.Vector; | import java.util.Vector; | ||||
import junit.framework.AssertionFailedError; | import junit.framework.AssertionFailedError; | ||||
import junit.framework.Test; | import junit.framework.Test; | ||||
import junit.framework.TestCase; | |||||
import junit.framework.TestFailure; | import junit.framework.TestFailure; | ||||
import junit.framework.TestListener; | import junit.framework.TestListener; | ||||
import junit.framework.TestResult; | import junit.framework.TestResult; | ||||
@@ -71,7 +73,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
/** | /** | ||||
* Holds the registered formatters. | * Holds the registered formatters. | ||||
*/ | */ | ||||
private Vector formatters = new Vector(); | |||||
private Vector<JUnitTaskMirror.JUnitResultFormatterMirror> formatters = new Vector(); | |||||
/** | /** | ||||
* Collects TestResults. | * Collects TestResults. | ||||
@@ -463,6 +465,13 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} | } | ||||
junit4 = junit4TestAdapterClass != null; | junit4 = junit4TestAdapterClass != null; | ||||
if (junitTest.isSkipNonTests()) { | |||||
if (!containsTests( testClass, junit4)) { | |||||
return; | |||||
} | |||||
} | |||||
if (junit4) { | if (junit4) { | ||||
// Let's use it! | // Let's use it! | ||||
Class[] formalParams; | Class[] formalParams; | ||||
@@ -563,6 +572,93 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} | } | ||||
} | } | ||||
private static boolean containsTests(Class<?> testClass, boolean isJUnit4) { | |||||
Class testAnnotation = null; | |||||
Class suiteAnnotation = null; | |||||
Class runWithAnnotation = null; | |||||
try { | |||||
testAnnotation = Class.forName("org.junit.Test"); | |||||
} catch (ClassNotFoundException e) { | |||||
if (isJUnit4) { | |||||
// odd - we think we're JUnit4 but don't support the test annotation. We therefore can't have any tests! | |||||
return false; | |||||
} | |||||
// else... we're a JUnit3 test and don't need the annotation | |||||
} | |||||
try { | |||||
suiteAnnotation = Class.forName("org.junit.Suite.SuiteClasses"); | |||||
} catch(ClassNotFoundException ex) { | |||||
// ignore - we don't have this annotation so make sure we don't check for it | |||||
} | |||||
try { | |||||
runWithAnnotation = Class.forName("org.junit.runner.RunWith"); | |||||
} catch(ClassNotFoundException ex) { | |||||
// also ignore as this annotation doesn't exist so tests can't use it | |||||
} | |||||
if (!isJUnit4 && !TestCase.class.isAssignableFrom(testClass)) { | |||||
//a test we think is JUnit3 but does not extend TestCase. Can't really be a test. | |||||
return false; | |||||
} | |||||
// check if we have any inner classes that contain suitable test methods | |||||
for (Class<?> innerClass : testClass.getDeclaredClasses()) { | |||||
if (containsTests(innerClass, isJUnit4) || containsTests(innerClass, !isJUnit4)) { | |||||
return true; | |||||
} | |||||
} | |||||
if (Modifier.isAbstract(testClass.getModifiers()) || Modifier.isInterface(testClass.getModifiers())) { | |||||
// can't instantiate class and no inner classes are tests either | |||||
return false; | |||||
} | |||||
if (isJUnit4) { | |||||
if (suiteAnnotation != null && testClass.getAnnotation(suiteAnnotation) != null) { | |||||
// class is marked as a suite. Let JUnit try and work its magic on it. | |||||
return true; | |||||
} | |||||
if (runWithAnnotation != null && testClass.getAnnotation(runWithAnnotation) != null) { | |||||
/* Class is marked with @RunWith. If this class is badly written (no test methods, multiple | |||||
* constructors, private constructor etc) then the class is automatically run and fails in the | |||||
* IDEs I've tried... so I'm happy handing the class to JUnit to try and run, and let JUnit | |||||
* report a failure if a bad test case is provided. Trying to do anything else is likely to | |||||
* result in us filtering out cases that could be valid for future versions of JUnit so would | |||||
* just increase future maintenance work. | |||||
*/ | |||||
return true; | |||||
} | |||||
} | |||||
for (Method m : testClass.getMethods()) { | |||||
if (isJUnit4) { | |||||
// check if suspected JUnit4 classes have methods with @Test annotation | |||||
if (m.getAnnotation(testAnnotation) != null) { | |||||
return true; | |||||
} | |||||
} else { | |||||
// check if JUnit3 class have public or protected no-args methods starting with names starting with test | |||||
if (m.getName().startsWith("test") && m.getParameterTypes().length == 0 | |||||
&& (Modifier.isProtected(m.getModifiers()) || Modifier.isPublic(m.getModifiers()))) { | |||||
return true; | |||||
} | |||||
} | |||||
// check if JUnit3 or JUnit4 test have a public or protected, static, | |||||
// no-args 'suite' method | |||||
if (m.getName().equals("suite") && m.getParameterTypes().length == 0 | |||||
&& (Modifier.isProtected(m.getModifiers()) || Modifier.isPublic(m.getModifiers())) | |||||
&& Modifier.isStatic(m.getModifiers())) { | |||||
return true; | |||||
} | |||||
} | |||||
// no test methods found | |||||
return false; | |||||
} | |||||
/** | /** | ||||
* Returns what System.exit() would return in the standalone version. | * Returns what System.exit() would return in the standalone version. | ||||
* | * | ||||
@@ -792,6 +888,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
boolean outputToFormat = true; | boolean outputToFormat = true; | ||||
boolean logFailedTests = true; | boolean logFailedTests = true; | ||||
boolean logTestListenerEvents = false; | boolean logTestListenerEvents = false; | ||||
boolean skipNonTests = false; | |||||
if (args.length == 0) { | if (args.length == 0) { | ||||
@@ -845,6 +942,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} else if (args[i].startsWith(Constants.LOG_FAILED_TESTS)) { | } else if (args[i].startsWith(Constants.LOG_FAILED_TESTS)) { | ||||
logFailedTests = Project.toBoolean( | logFailedTests = Project.toBoolean( | ||||
args[i].substring(Constants.LOG_FAILED_TESTS.length())); | args[i].substring(Constants.LOG_FAILED_TESTS.length())); | ||||
} else if (args[i].startsWith(Constants.SKIP_NON_TESTS)) { | |||||
skipNonTests = Project.toBoolean( | |||||
args[i].substring(Constants.SKIP_NON_TESTS.length())); | |||||
} | } | ||||
} | } | ||||
@@ -884,6 +984,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
t.setTodir(new File(st.nextToken())); | t.setTodir(new File(st.nextToken())); | ||||
t.setOutfile(st.nextToken()); | t.setOutfile(st.nextToken()); | ||||
t.setProperties(props); | t.setProperties(props); | ||||
t.setSkipNonTests(skipNonTests); | |||||
code = launch(t, testMethodNames, haltError, stackfilter, haltFail, | code = launch(t, testMethodNames, haltError, stackfilter, haltFail, | ||||
showOut, outputToFormat, | showOut, outputToFormat, | ||||
logTestListenerEvents); | logTestListenerEvents); | ||||
@@ -911,6 +1012,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} else { | } else { | ||||
JUnitTest t = new JUnitTest(args[0]); | JUnitTest t = new JUnitTest(args[0]); | ||||
t.setProperties(props); | t.setProperties(props); | ||||
t.setSkipNonTests(skipNonTests); | |||||
returnCode = launch( | returnCode = launch( | ||||
t, methods, haltError, stackfilter, haltFail, | t, methods, haltError, stackfilter, haltFail, | ||||
showOut, outputToFormat, logTestListenerEvents); | showOut, outputToFormat, logTestListenerEvents); | ||||
@@ -333,4 +333,29 @@ public class JUnitTaskTest extends BuildFileTest { | |||||
executeTarget("testTestMethods"); | executeTarget("testTestMethods"); | ||||
} | } | ||||
public void testNonTestsSkipped() throws Exception { | |||||
executeTarget("testNonTests"); | |||||
assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.NonTestMissed.xml").isExists()); | |||||
assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3TestMissed.xml").isExists()); | |||||
assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractTestMissed.xml").isExists()); | |||||
assertFalse("Test result should not exist as test was skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractJUnit3TestMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractTestNotMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractJUnit3TestNotMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.TestNotMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3TestNotMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.TestWithSuiteNotMissed.xml").isExists()); | |||||
executeTarget("testNonTestsRun"); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.NonTestMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3NonTestMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.TestNotMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3TestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3TestNotMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractTestMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractTestNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractTestNotMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.AbstractJUnit3TestMissed.xml", getProject().getResource("out/TEST-org.example.junit.AbstractJUnit3TestMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.JUnit3NonTestMissed.xml", getProject().getResource("out/TEST-org.example.junit.JUnit3NonTestMissed.xml").isExists()); | |||||
assertTrue("Test result should exist as test was not skipped - TEST-org.example.junit.TestWithSuiteNotMissed.xml", getProject().getResource("out/TEST-org.example.junit.TestWithSuiteNotMissed.xml").isExists()); | |||||
} | |||||
} | } |
@@ -0,0 +1,27 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.example.junit; | |||||
import junit.framework.TestCase; | |||||
public abstract class AbstractJUnit3TestMissed extends TestCase { | |||||
public void testNothing() { | |||||
} | |||||
} |
@@ -0,0 +1,31 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.example.junit; | |||||
import junit.framework.TestCase; | |||||
public abstract class AbstractJUnit3TestNotMissed extends TestCase { | |||||
public void testNothing() { | |||||
} | |||||
public static class InnerAbstractTestNotMissed extends AbstractJUnit3TestNotMissed { | |||||
} | |||||
} |
@@ -0,0 +1,29 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.example.junit; | |||||
import org.junit.Test; | |||||
public abstract class AbstractTestMissed { | |||||
@Test | |||||
public void testNothing() { | |||||
} | |||||
} |
@@ -0,0 +1,32 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.example.junit; | |||||
import org.junit.Test; | |||||
public abstract class AbstractTestNotMissed { | |||||
@Test | |||||
public void testNothing() { | |||||
} | |||||
public static class InnerAbstractTestNotMissed extends AbstractTestNotMissed { | |||||
} | |||||
} |
@@ -0,0 +1,27 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.example.junit; | |||||
import junit.framework.TestCase; | |||||
public class JUnit3NonTestMissed extends TestCase { | |||||
public void notATest() { | |||||
//this isn't a test but shouldn't case an error | |||||
} | |||||
} |
@@ -0,0 +1,28 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.example.junit; | |||||
import junit.framework.TestCase; | |||||
public class JUnit3TestNotMissed extends TestCase { | |||||
public void testNothing() { | |||||
// don't fail | |||||
} | |||||
} |
@@ -0,0 +1,25 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.example.junit; | |||||
public class NonTestMissed { | |||||
public void notATest() { | |||||
//this isn't a test but shouldn't case an error | |||||
} | |||||
} |
@@ -0,0 +1,29 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.example.junit; | |||||
import org.junit.Test; | |||||
public class TestNotMissed { | |||||
@Test | |||||
public void testNothing() { | |||||
// don't fail | |||||
} | |||||
} |
@@ -0,0 +1,32 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
* (the "License"); you may not use this file except in compliance with | |||||
* the License. You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
package org.example.junit; | |||||
import junit.framework.Test; | |||||
import junit.framework.TestSuite; | |||||
public class TestWithSuiteNotMissed { | |||||
public static Test suite() { | |||||
TestSuite test = new TestSuite("meh"); | |||||
JUnit3TestNotMissed testCase = new JUnit3TestNotMissed(); | |||||
testCase.setName("testNothing"); | |||||
test.addTest(testCase); | |||||
return test; | |||||
} | |||||
} |