`
jadewoo
  • 浏览: 85267 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

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<ComicCmsdata> l = sds.findAll();
System.out.println("l.size():"+l.size());
for(ComicCmsdata c : l){
System.out.println(c.getId().getRetParm1()+" "+c.getId().getRetParm2());
}
}
}

用junit Test运行后,出现如下的错误: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)

解决办法:
在测试办法前面加test,即把getAll()改为testGetALl()。这样后就可以运行了
分享到:
评论
1 楼 s_huaiqi 2016-05-12  
点103个赞

相关推荐

    junit的jar包

    junit.framework.AssertionFailedError.class junit.framework.ComparisonCompactor.class junit.framework.ComparisonFailure.class junit.framework.JUnit4TestAdapter.class junit.framework.JUnit4...

    junit-jupiter-api-5.4.2-API文档-中英对照版.zip

    Maven坐标:org.junit.jupiter:junit-jupiter-api:5.4.2; 标签:junit、jupiter、api、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化...

    junit-jupiter-api-5.8.2-API文档-中文版.zip

    Maven坐标:org.junit.jupiter:junit-jupiter-api:5.8.2; 标签:junit、jupiter、api、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,...

    junit-jupiter-engine-5.8.2-API文档-中文版.zip

    Maven坐标:org.junit.jupiter:junit-jupiter-engine:5.8.2; 标签:junit、engine、jupiter、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化...

    junit-jupiter-api-5.6.3.jar中文-英文对照文档.zip

    注:下文中的 *** 代表文件名中的组件名称。 # 包含: 中文-英文对照文档:【***-javadoc-API文档-中文(简体)-英语-对照版.zip】 jar包下载地址:【***.jar下载地址(官方地址+国内镜像地址).txt】 ...

    junit-4.12.rar包及依赖包

    使用JUnit 4进行单元测试时,测试程序一直运行失败,报method initializationerror not found错误,添加以下几个jar包即可解决问题,希望可以帮助大家。

    org.eclipse.jdt.core_3.5.2.v_981_R35x

    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners....

    junit-vintage-engine-5.6.2.jar_junit testng

    junit-vintage-engine-5.6.2.jarjunit-vintage-engine-5.6.2.jarjunit-vintage-engine-5.6.2.jar

    Testing.with.Junit.1782166602

    JUnit has matured to become the most important tool when it comes to automated developer tests in Java. Supported by all IDEs and build systems, it empowers programmers to deliver software features ...

    junit-jupiter-api-5.8.0-M1-API文档-中英对照版.zip

    Maven坐标:org.junit.jupiter:junit-jupiter-api:5.8.0-M1; 标签:junit、jupiter、api、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性...

    junit-jupiter-engine-5.8.0-M1-API文档-中文版.zip

    Maven坐标:org.junit.jupiter:junit-jupiter-engine:5.8.0-M1; 标签:junit、jupiter、engine、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 ...

    HIbernate4.3.6整合c3p0所需jar

    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners....

    jaxen.jar和dom4j.jar

    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners....

    STA2JUnit Framework

    STA2JUnit Framework.ppt STA2JUnit Framework.ppt STA2JUnit Framework.ppt

    Maven更新失败,Cannot resolve plugin org.apache.maven.plugins:maven-compiler-plugin:3.1

    今天Maven在更新的时候发现一直更新不成功,总结下解决方法。 在apache-maven-3.5.2/conf/setting.xml中加入以下配置即可解决 alimaven aliyun maven ...

    初试android studio 创建project时报错:Could not download junit.jar(junit:junit:4.12)

    于是在去百度怎么解决,解决方式为:下载不到junit的jar包,应该是网络问题,junit是测试用的。如果不在意的话,可以不下载它,在module的build.gradle中dependencies模块把加载junit的testCompile ‘junit:j

    Junit单元测试所需要的两个jar包

    1 Junit是什么 JUnit 是一个 Java 编程语言的单元测试框架。JUnit 在测试驱动的开发方面有很重要的发展,是起源于 JUnit 的一个统称为 xUnit 的单元测试框架之一。 2 单元测试概念 单元:在Java中,一个类就是一个...

    junit.jar

    junit.jar junit.jar

    junit.jar包

    org.junit4.nl_zh_3.6.0.v20100814043401 android studio 报错缺少junit.jar包问题 放到D:\Program Files\Android\Android Studio\gradle\gradle-4.1\lib\plugins(路径要与自己的对应)

    com.google.android:flexbox:0.3.0-alpha2依赖资源

    要在主工程的gradle中添加版本信息或者自己在资源包中添加版本号,依赖此资源就可以实现FlexboxLayout与Recycleview的后续操作,我的主工程版本代码: ext { minSdkVersion = 9 ... junitVersion = "4.12" }

Global site tag (gtag.js) - Google Analytics