title: Does JUnit4 testclasses require a public no arg constructor?
body: <p>I have a test class, written in JUnit4 syntax, that can be run in eclipse with the "run as junit test" option without failing. When I run the same test via an ant target I get this error:</p>
  
  <pre><code>java.lang.Exception: Test class should have public zero-argument constructor
  at org.junit.internal.runners.MethodValidator.validateNoArgConstructor(MethodValidator.java:54)
  at org.junit.internal.runners.MethodValidator.validateAllMethods(MethodValidator.java:39)
  at org.junit.internal.runners.TestClassRunner.validate(TestClassRunner.java:33)
  at org.junit.internal.runners.TestClassRunner.&lt;init&gt;(TestClassRunner.java:27)
  at org.junit.internal.runners.TestClassRunner.&lt;init&gt;(TestClassRunner.java:20)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
  at junit.framework.JUnit4TestAdapter.&lt;init&gt;(JUnit4TestAdapter.java:24)
  at junit.framework.JUnit4TestAdapter.&lt;init&gt;(JUnit4TestAdapter.java:17)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:386)
  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:911)
  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:768)
  Caused by: java.lang.NoSuchMethodException: dk.gensam.gaia.business.bonusregulering.TestBonusregulerAftale$Test1Reader.&lt;init&gt;()
  at java.lang.Class.getConstructor0(Class.java:2706)
  at java.lang.Class.getConstructor(Class.java:1657)
  at org.junit.internal.runners.MethodValidator.validateNoArgConstructor(MethodValidator.java:52)
  </code></pre>
  
  <p>I have no public no arg constructor in the class, but is this really necessary?</p>
  
  <p>This is my ant target    </p>
  
  <pre><code>&lt;target name="junit" description="Execute unit tests" depends="compile, jar-test"&gt;
          &lt;delete dir="tmp/rawtestoutput"/&gt;
          &lt;delete dir="test-reports"/&gt;
          &lt;mkdir dir="tmp/rawtestoutput"/&gt;
          &lt;junit printsummary="true" failureproperty="junit.failure" fork="true"&gt;
            &lt;classpath refid="class.path.test"/&gt;
            &lt;classpath refid="class.path.model"/&gt;
            &lt;classpath refid="class.path.gui"/&gt;
            &lt;classpath refid="class.path.jfreereport"/&gt;
              &lt;classpath path="tmp/${test.jar}"&gt;&lt;/classpath&gt;
            &lt;batchtest todir="tmp/rawtestoutput"&gt;
              &lt;fileset dir="${build}/test"&gt;
                  &lt;include name="**/*Test.class" /&gt;
                  &lt;include name="**/Test*.class" /&gt;
              &lt;/fileset&gt;
            &lt;/batchtest&gt;
          &lt;/junit&gt;
          &lt;junitreport todir="tmp"&gt;
            &lt;fileset dir="tmp/rawtestoutput"/&gt;
            &lt;report todir="test-reports"/&gt;
          &lt;/junitreport&gt;
          &lt;fail if="junit.
  failure" message="Unit test(s) failed.  See reports!"/&gt;
      &lt;/target&gt;
  </code></pre>
  
  <p>The test class have no constructors, but it has an inner class with default modifier. It also have an anonymouse inner class. Both inner classes gives the "Test class should have public zero-argument constructor error". I am using Ant version 1.7.1 and JUnit 4.7</p>