您的位置:首页 > 编程语言 > Java开发

JUnit单元测试中获取Spring中的bean测试类的编写

2019-02-15 14:37 274 查看

1、编写测试类

[code]import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.hp.approval.single.impl.SingleInterfaceManager;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath*:/spring/context-*.xml"})//从web.xml中获取contextConfigLocation路径
public class TestInterface {

@Autowired

private SingleInterfaceManager manager;

@Test
public void TestApproval(){
manager.checkSingleApproval();
}

}

2.web.xml格式

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐