Is it possible to run JMeter with the JUnit plugin/sampler and Spring Java configuration? When I try to do this, the Spring autowired beans are not being created and although the test case runs, because the beans have not been created, I get null pointer exceptions.
I am using the Spring annotation
@SpringJUnit4ClassRunner
and @ContextConfiguration
to configure the JUnit test (which works). The goal is to be able to write JUnit test cases that can be measured for performance using JMeter.
Yes, running JMeter with JUnit and Spring is a problem.
JMeter does not use standard JUnit runner; its specified at
User manual, point 7. There are subtle differences between standard JUnit test runners and JMeter's implementation. Because of this, @SpringJUnit4ClassRunner
is becomes ignored. Workaround is to load beans as normal i.e using ApplicationContext.getBean()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With