我的JUnit测试定义如下:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/spring-test.xml" })
public abstract class MyTest {但是,当我尝试使用JMeter运行它时,它似乎不再设置xml文件中定义的spring依赖项,似乎这个RunWith注释被忽略了。当我尝试使用弹簧注入的deps时,我得到了NPE。有解决方案吗?如何正确地解决它?
发布于 2013-06-26 22:28:48
JUnit采样器实现没有使用标准的JUnit运行器工具。请参阅文档(http://jmeter.apache.org/usermanual/component_reference.html#JUnit_Request)中的第7点。
另请阅读此门票中的讨论:https://issues.apache.org/bugzilla/show_bug.cgi?id=47888#c1。
如果你对它的实现感兴趣,可以看看org.apache.jmeter.protocol.java.sampler.JUnitSampler。
发布于 2013-06-28 06:10:02
几天来我一直在试着做同样的事情。
但是注解有问题。
它在没有使用注释的情况下在jmeter中运行,比如使用以下命令加载上下文:
ApplicationContext context = new FileSystemXmlApplicationContext("Spring-Module.xml");
context.getBean("helloWorld");https://stackoverflow.com/questions/17320253
复制相似问题