junit报错
java.lang.RuntimeException: iwap 环境还没有初始化,请先调用IWapContext.init()。
 at com.nantian.ofpiwap.IWapContext.checkInit(IWapContext.java:402)
 at com.nantian.ofpiwap.IWapContext.getContext(IWapContext.java:348)
 at demo.TestHelloWorld.testGreeting(TestHelloWorld.java:14)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at junit.framework.TestCase.runTest(TestCase.java:154)
 at junit.framework.TestCase.runBare(TestCase.java:127)
 at junit.framework.TestResult$1.protect(TestResult.java:106)
 at junit.framework.TestResult.runProtected(TestResult.java:124)
 at junit.framework.TestResult.run(TestResult.java:109)
 at junit.framework.TestCase.run(TestCase.java:118)
 at junit.framework.TestSuite.runTest(TestSuite.java:208)
 at junit.framework.TestSuite.run(TestSuite.java:203)
 at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
 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)
解决方法:
package demo;
import org.springframework.context.ApplicationContext; 
  import com.nantian.ofpiwap.IWapContext;
  import junit.framework.TestCase; 
  /**
   * 测试greeting函数
   */
  public class TestHelloWorld extends TestCase {
    /**
     * 测试greeting函数
     */
    public void testGreeting() {
    	IWapContext.init();
        ApplicationContext context = IWapContext.getContext();
        HelloWorld helloWorld = (HelloWorld) context.getBean("HelloWorld");
        String accountName = helloWorld.greeting("admin");
        assertEquals("管理员", accountName);
    }
  }
junit报错的更多相关文章
- 【Junit 报错】No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
		Junit报错 log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvi ... 
- 【JUnit  报错】java.lang.IncompatibleClassChangeError
		使用Junit 测试spring时候报错: java.lang.IncompatibleClassChangeError: class org.springframework.core.LocalVa ... 
- 【JUnit   报错】java.lang.NoClassDefFoundError: org/apache/logging/log4j/message/Message
		使用JUnit的时候,报错:java.lang.NoClassDefFoundError: org/apache/logging/log4j/message/Message 原因是因为项目中导入的架包 ... 
- 【JUnit   报错】  method initializationerror not found:JUnit4单元测试报错问题
		今天是用JUnit测试一段代码,报错method initializationerror not found::出现如下问题: 双击这个就显示出现如下的错误: 查询网上,说是junit版本的问题: 那 ... 
- spring整合junit报错
		1.Could not autowire field: private javax.servlet.http.HttpServletRequest 参考:https://www.cnblogs.com ... 
- MyEclipse下Junit报错"The input type of the launch configuration"
		MyEclipse下Junit运行测试用例的时候报错: "The input type of the launch configuration does not exist" 原因 ... 
- Spring+Hibernate4 Junit 报错No Session found for current thread
		论坛上有另外一篇更全面的帖子,jinnianshilongnian写的:http://www.iteye.com/topic/1120924 本文的环境是: spring-framework-3.1 ... 
- Junit 报错: Failed to load ApplicationContext
		今天在使用Junit测试时候,报了个错误: Failed to load ApplicationContext, aspect not found;挺奇怪的 我又没有调用你,之前还好好的,现在不能使用 ... 
- JUnit报错:java.lang.ClassNotFoundException: com.mogodb.test.test
		最近在使用JUnit做单元测试时,发现新写好的测试类运行总是出错,报找不到类异常. Class not found com.mogodb.test.test java.lang.ClassNotFou ... 
- 【Junit 报错】Test class should have exactly one public zero-argument constructor和Test class can only have one constructor
		错误1: java.lang.Exception: Test class should have exactly one public zero-argument constructor at org ... 
随机推荐
- 07 IO流(四)——文件字节流 FileInputStream/FileOutputStream与文件的拷贝
			两个类的简述 专门用来对文件进行读写的类. 父类是InputStream.OutputStream 文件读入细节 FileOutputStream流的构造方法:new FileOutputStream ... 
- WUSTOJ 1296: JAM计数法(Java)
			题目链接: 
- IdentityServer4 手动验签及日志记录
			IdentityServer4的基础知识和使用方式网上有很多特别优秀的文章,如果有对其不了解的推荐阅读一下下面的两篇文章 http://www.ruanyifeng.com/blog/2014/05/ ... 
- jmeter保存返回数据到csv
			添加一个线程组,然后右键选择“正则表达式提取器” 配置正则表达式: 添加添加后置处理器beanshell postprocessor: 保存提取的数据: 代码: FileWriter fstream ... 
- Spring高级进阶:BeanFactoryPostProcessor
			BeanFactoryPostProcessor是实现spring容器功能扩展的重要接口,例如修改bean属性值,实现bean动态代理等.很多框架都是通过此接口实现对spring容器的扩展,例如myb ... 
- 在论坛中出现的比较难的sql问题:45(用户在线登陆时间的小时、分钟计算问题)
			原文:在论坛中出现的比较难的sql问题:45(用户在线登陆时间的小时.分钟计算问题) 最近,在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘记解决的方法了. ... 
- Asp.net Report动态生成
			rdlc报表实质上是一个xml文件,如果要实现动态报表,就需要动态生成rdlc文件,实质上就是读写xml文件: protected XmlDocument GenerationAddReportCol ... 
- sql语句中包含引号处理方法
			1. 背景 在使用Python脚本向数据库导入日志文件时候,突然报错. 2. 解决思路 查看messages文件,发现有一条语句里包含单引号. 查看sql语句,是使用单引号标注str类型. 3. 得出 ... 
- 简单记录一次注入到shell
			0x00 前言 帮朋友之前拿的一个站,有点久了没有完整截图,简单记录一下. 0x01 基础信息 操作系统:win 集成环境:phpstudy 端口开放:82,3306,3389 有phpmyadmin ... 
- jquery sortable的拖动方法示例详解1
			转自:https://www.jb51.net/article/45803.htm 所有的事件回调函数都有两个参数:event和ui,浏览器自有event对象,和经过封装的ui对象 ui.helper ... 
