11

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.

kryger
  • 12,906
  • 8
  • 44
  • 65
Joe
  • 121
  • 1
  • 8

1 Answers1

4

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

dur
  • 15,689
  • 25
  • 79
  • 125
Nikhil Bhide
  • 728
  • 8
  • 23