Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter, JUnit and Spring Java configuration

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.

like image 434
Joe Avatar asked Nov 17 '15 03:11

Joe


1 Answers

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().

like image 165
Nikhil Bhide Avatar answered Nov 04 '22 16:11

Nikhil Bhide