You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Ahmad Hasbini <a....@gmail.com> on 2020/08/23 11:34:22 UTC

A flexible approach to JUnit Runner integrations

Hello,

I've been looking into how to use Jmeter with JUnit tests that are using
the SpringJUnit4ClassRunner, the reason behind using it is to autowire the
beans. Upon understanding the current implementation of the JunitSampler, I
thought of the following enhancement:

   - Use the JUnit runner instead of the current implementation which can
   take care of the setup for the test class(es) and the test method
   invocation.
   - Attach test and run listeners to monitor the progress and results of
   the test case to fill in the SampleResult(s).
   - Have all of this logic implemented in a Sampler so it can be easily
   used with Jmeter.

I'm wondering if anything on this topic was discussed before. I feel that
the downsides of this approach is probably the time JUnit runners take to
instantiate and setup or even the increased memory consumption compared to
the current lightweight implementation. I'm looking forward to any thoughts
and feedback on this as I'm currently trying an implementation of my own.

Thanks in advance and best regards,
Ahmad Hasbini

Re: A flexible approach to JUnit Runner integrations

Posted by Felix Schumacher <fe...@internetallee.de>.
Am 23.08.20 um 13:34 schrieb Ahmad Hasbini:
> Hello,
>
> I've been looking into how to use Jmeter with JUnit tests that are using
> the SpringJUnit4ClassRunner, the reason behind using it is to autowire the
> beans. Upon understanding the current implementation of the JunitSampler, I
> thought of the following enhancement:
>
>    - Use the JUnit runner instead of the current implementation which can
>    take care of the setup for the test class(es) and the test method
>    invocation.
>    - Attach test and run listeners to monitor the progress and results of
>    the test case to fill in the SampleResult(s).
>    - Have all of this logic implemented in a Sampler so it can be easily
>    used with Jmeter.
>
> I'm wondering if anything on this topic was discussed before. I feel that
> the downsides of this approach is probably the time JUnit runners take to
> instantiate and setup or even the increased memory consumption compared to
> the current lightweight implementation. I'm looking forward to any thoughts
> and feedback on this as I'm currently trying an implementation of my own.

I don't use the JUnit Sampler myself, so I have little knowledge, of
what it can do, or what it would still need to have.

But if you think it is missing something, you have a few possibilities:

 * Implement your own sampler and publish it as a third-party plugin

 * Try to enhance the current sampler in a way, it stays compatible with
old versions while not getting too complex

A few general thoughts. Can the JUnit runner be used in a concurrent
setup? If you think it might be "expensive" to set up JUnit, would it be
feasible to extract the expensive part in a controller or something like
that?

Felix

>
> Thanks in advance and best regards,
> Ahmad Hasbini
>