How to implement parallel execution of JUnit tests in AEM as a Cloud Service? | Adobe Higher Education
Skip to main content
rampai
Community Advisor
Community Advisor
March 28, 2025
解決済み

How to implement parallel execution of JUnit tests in AEM as a Cloud Service?

  • March 28, 2025
  • 3 の返信
  • 1038 ビュー

Hi All,

 

Has anyone done JUnit test execution in parallel mode in AEM Cloud? If yes, are any changes needed in Cloud Manager that we need to reach out to Adobe for?

 

I have tried updating junit-platform.properties under /src/test/resources but could not see any improvement in deployment time.

 

Please could someone advise.

 

Thanks,

Ram

このトピックへの返信は締め切られました。
ベストアンサー narendiran_ravi

I have tested this configuration in the Cloud Sandbox pipeline, and it has successfully reduced the build time.

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <parallel>all</parallel> <!-- "methods" or "both" can also be used --> <threadCount>3</threadCount> <!-- Number of threads for parallel test execution --> <forkCount>3</forkCount> <!-- Number of JVM forks --> <reuseForks>true</reuseForks> <!-- Reuse forked JVMs for tests --> <useSystemClassLoader>false</useSystemClassLoader> </configuration> </plugin>

 

3 の返信

giuseppebaglio
Level 10
March 28, 2025

hi @rampai

In one of the projects I worked on, we implemented a CI/CD pipeline where the code was built in both our Jenkins instances and AEM CM in parallel. The CM outcome was mandatory for successfully completing the pipeline.

 

When we introduced parallel execution for JUnit tests, the build processing time dramatically decreased. TBH We also made some adjustments to test classes that contributed to this improvement. However, we remained dependent on the CM result. To address this, we updated our pipeline to generate visible reports before receiving the CM outcome. This allowed developers to check for any violations or issues raised from the SonarQube reports sooner.

 

In conclusion, I highly recommend using JUnit parallel execution because, with the right settings, it significantly speeds up development times.

rampai
Community Advisor
rampaiCommunity Advisor作成者
Community Advisor
April 1, 2025

Thanks @giuseppebaglio ,

 

Please could you confirm what adjustments you had to make to test classes as part of this improvement.

 

Regards,

Ram

giuseppebaglio
Level 10
April 1, 2025

I refactored test initialization so that heavyweight objects or resources (like database connections, file I/O, Context-Aware configs) are set up only once per test suite rather than before each test: I used class-level setup methods (for example, using JUnit’s @BeforeAll) to share common resources.

Where possible, I reused objects across multiple tests rather than instantiating them repeatedly.
Cached results or configurations that do not change between tests to cut down on repeated computation.

 
narendiran_ravi
Level 6
March 28, 2025

I have tested this configuration in the Cloud Sandbox pipeline, and it has successfully reduced the build time.

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <parallel>all</parallel> <!-- "methods" or "both" can also be used --> <threadCount>3</threadCount> <!-- Number of threads for parallel test execution --> <forkCount>3</forkCount> <!-- Number of JVM forks --> <reuseForks>true</reuseForks> <!-- Reuse forked JVMs for tests --> <useSystemClassLoader>false</useSystemClassLoader> </configuration> </plugin>

 

rampai
Community Advisor
rampaiCommunity Advisor作成者
Community Advisor
April 1, 2025

Thanks @narendiran_ravi , 

 

I am checking this in my project. Will confirm if it worked.

 

Regards,

Ram

kautuk_sahni
Community Manager
Community Manager
April 1, 2025

@rampai Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Kautuk Sahni