You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Kamalpreet Kaur <km...@gmail.com> on 2022/11/29 10:44:51 UTC

Fwd: Injecting JUnit-4 Parallel Execution Parameters in Surefire Plugin

Hi Everyone,

I'm currently creating a package from where I would want to set JUnit
parallel execution parameters like below :

*<parallel>classesAndMethods</parallel>
<threadCountClasses>1</threadCountClasses>
<threadCountMethods>1</threadCountMethods>
<perCoreThreadCount>false</perCoreThreadCount>*

I'm planning to use Instrumentation API to inject these parameters. I tried
to find the correct place where I can do so, but failed to find one.

Please point me to a class from where these values are being honoured So
that I could inject these parameters there. You could also suggest a way to
set these values apart from adding them to the <configuration> element.

I tried intercepting different surefire classes like ForkedBooter,
JUnit4Provider, JUnitCoreProvider but after that the execution didn't
happen according to specified parameters.

-- 
Thanks & Regards
Kamalpreet Kaur

Re: Injecting JUnit-4 Parallel Execution Parameters in Surefire Plugin

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

Did you check these classes:
->
https://github.com/apache/maven-surefire/blob/b9b2381a3dba6574bb69bd91d45fe0edea29c779/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java#L73
->
https://github.com/apache/maven-surefire/blob/79db90338fb474f91c76991388a35bc412ee1d46/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java#L119

That said the best to inject these parameters is to write a maven extension
and rewrite surefire <configuration> block, it is way easier.


Out of curiosity, what's the goal of writing the configuration not using
the configuration block?

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le mer. 30 nov. 2022 à 00:44, Kamalpreet Kaur <km...@gmail.com> a
écrit :

> Hi Everyone,
>
> I'm currently creating a package from where I would want to set JUnit
> parallel execution parameters like below :
>
> *<parallel>classesAndMethods</parallel>
> <threadCountClasses>1</threadCountClasses>
> <threadCountMethods>1</threadCountMethods>
> <perCoreThreadCount>false</perCoreThreadCount>*
>
> I'm planning to use Instrumentation API to inject these parameters. I tried
> to find the correct place where I can do so, but failed to find one.
>
> Please point me to a class from where these values are being honoured So
> that I could inject these parameters there. You could also suggest a way to
> set these values apart from adding them to the <configuration> element.
>
> I tried intercepting different surefire classes like ForkedBooter,
> JUnit4Provider, JUnitCoreProvider but after that the execution didn't
> happen according to specified parameters.
>
> --
> Thanks & Regards
> Kamalpreet Kaur
>