Tomcat下的奇怪错误Junit

Tomcat下的奇怪错误Junit,tomcat,junit4,Tomcat,Junit4,我正在开发一个java web应用程序,它使用运行JUnit 4.10测试(forward T)的其他项目。T项目也从命令行完美地执行测试和测试。当我从运行在Tomcat7上的应用程序(我没有尝试过其他版本)调用它时,问题出现了:initializationError(TestName),没有可运行的方法 以下是测试运行程序代码: public ResultadoPrueba ejecuta() { List<String> LClassPathEjecuci

我正在开发一个java web应用程序,它使用运行JUnit 4.10测试(forward T)的其他项目。T项目也从命令行完美地执行测试和测试。当我从运行在Tomcat7上的应用程序(我没有尝试过其他版本)调用它时,问题出现了:initializationError(TestName),没有可运行的方法

以下是测试运行程序代码:

    public ResultadoPrueba ejecuta() {
        List<String> LClassPathEjecucion = new ArrayList<String>();
        LClassPathEjecucion.addAll(this.LdirectoriosPrueba);
        LClassPathEjecucion.addAll(this.LdirectorioBaseCodigoPractica);
        LClassPathEjecucion.addAll(this.LclassPathNecesarioEjecutor);
        URL[] lClassPath = List2URL(LClassPathEjecucion);
        URLClassLoader cl = new URLClassLoader(lClassPath);
        Class<?>[] cClases = new Class<?>[this.LclasesTest.size()];
        for (int i = 0; i < this.LclasesTest.size(); i++) {
            try {
                cClases[i] = cl.loadClass(this.LclasesTest.get(i).toString());
                log.debug("CLASE " + this.LclasesTest.get(i).toString());
                for (int j = 0; j < cClases[i].getDeclaredMethods().length; j++) {                               
                    log.debug("\t" + cClases[i].getDeclaredMethods()[j].getName());
                    for (int k =0; k<cClases[i].getDeclaredMethods()[j].getAnnotations().length;k++) {
                        log.debug("\t\t"+ cClases[i].getDeclaredMethods()[j].getAnnotations()[k].toString());
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        Request req = Request.classes(cClases);
        JUnitCore jUnitCore = new JUnitCore();
        log.debug("Version de jUnitCore " + jUnitCore.getVersion());
        //jUnitCore.addListener(new TextListener(System.out));
        ListenerPruebas listener = new ListenerPruebas();
        jUnitCore.addListener(listener);
        Result resultadoJUnit = jUnitCore.run(req);
        ResultadoPrueba resultado = new ResultadoPrueba();
        resultado.setResultado(resultadoJUnit);
        resultado.setEjecutados(listener.getResultados());
        resultado.setFallos(listener.getFallos());
        return resultado;
    }
}

这是一个愚蠢的junit 4测试…

我尝试了Glassfish 3.1,但也遇到了同样的情况,我也将代码移到了web项目中,我遇到了同样的问题…我在这里找到了解决方案,我还不了解原因,但建议的修复方案有效。
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class JTestDummyTested {

    private DummyTested dummyTested ;

    @Before
    public void startUp(){      
           dummyTested = new DummyTested(1,1);
    }

    @Test
    public void testSuma() {
        assertEquals("1+1 deberian ser 2", 2.0, dummyTested.suma(), 1e-6);
    }

}