junit.framework.AssertionFailedError: No tests found in错误解决办法

代码如下:

import java.util.List;

import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;


public class Test extends TestCase {

private ApplicationContext context = null;

@Override
protected void setUp() throws Exception {

context = new FileSystemXmlApplicationContext(
"/WebRoot/WEB-INF/classes/applicationContext.xml");
}
@Override
protected void tearDown() throws Exception {

super.tearDown();
}

public void getALl(){
// ComicCmsdataService sds = (ComicCmsdataService)context.getBean("comicCmsdataService");
ComicCmsdataDAO sds = (ComicCmsdataDAO)context.getBean("ComicCmsdataDAO");
List l = sds.findAll();
System.out.println("l.size():"+l.size());
for(ComicCmsdata c : l){
System.out.println(c.getId().getRetParm1()+" "+c.getId().getRetParm2());
}
}
}

[b]用junit Test运行后,出现如下的错误:[/b]junit.framework.AssertionFailedError: No tests found in com.wichina.model.Test
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.TestSuite$1.runTest(TestSuite.java:97)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

[b]解决办法:[/b]
在测试办法前面加test,即把getAll()改为testGetALl()。这样后就可以运行了

你可能感兴趣的:(junit.framework.AssertionFailedError: No tests found in错误解决办法)