0
我们从运行JUnit通过Ant获得了这个错误,这个错误大部分都是写入的。我们再次检查了我们在前面关于这个错误的问题中看到的所有建议,看起来我们在我们的测试类中获得了所需的一切,公共无参数构造函数和带有注释的单个方法!Ant JUnit错误没有可运行的方法。 initializationError
Testsuite: sim.V
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.016 sec
Testcase: initializationError took 0.002 sec
Caused an ERROR
No runnable methods
java.lang.Exception: No runnable methods
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
Testsuite: simvim
这里是我们的Ant构建XML文件:
<target name="junit" depends="build">
<junit fork="no" printsummary="withOutAndErr">
<test name="sim.V" outfile="TB" />
<formatter usefile="true" type="plain"/>
<classpath>
<pathelement path="/afs/cad.njit.edu/u/j/g/jg284/libs/junit.jar"/>
<pathelement path="/afs/cad.njit.edu/u/j/g/jg284/libs/hamcrest-core-1.3.jar"/>
</classpath>
</junit>
</target>
下面是我们的测试类:
package sim;
import java.io.*;
import org.junit.*;
import static org.junit.Assert.*;
public class V {
public V() {
}
@Test
public void SG() throws IOException,sim.SE,Exception {
Simulation S = new Simulation();
S.logger = Simulate.createLogger("log.out","FINEST", false);
S.stat = Simulate.createLogger("logstat.out","FINEST", false);
sim.movers.SMover SM = new sim.movers.SMover(S);
SM.TB();
}
}
建议:使用标准的Java命名约定。 ClassesAreNamedLikeThis variablesAreNamedLikeThis soAreFields andMethods – NamshubWriter