2015-06-16 41 views
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(); 
    } 
} 
+0

建议:使用标准的Java命名约定。 ClassesAreNamedLikeThis variablesAreNamedLikeThis soAreFields andMethods – NamshubWriter

回答

0

尝试设置fork="yes"代替fork="no"。我能够用fork="no"而不是fork="yes"重现您的问题。我不能告诉你为什么它不适用于fork="no"。我会猜测Ant的某种类加载问题。我是从去年七月,他的作者提到花了一些时间,但谷歌搜索所有我能找到的a bug from 2006(这我不知道,因为我没有在ANT_HOME/libjunit4.jar做的是相关的),以及blog post是:

注意:如果你忘记设置叉属性设置为true,你会得到类似以下的错误信息:
(错误信息类似于省略你的)

相关问题