From b94ec58de3624c4ed69256160d3d63df9d0dd491 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Sat, 8 Jul 2023 15:31:13 +0200 Subject: [PATCH] Allow tests to run concurrently --- buildSrc/src/main/groovy/twomartens.java.gradle | 2 +- .../wahlrecht/service/CalculationServiceTest.java | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/groovy/twomartens.java.gradle b/buildSrc/src/main/groovy/twomartens.java.gradle index 6b5f55a..9b61efa 100644 --- a/buildSrc/src/main/groovy/twomartens.java.gradle +++ b/buildSrc/src/main/groovy/twomartens.java.gradle @@ -25,7 +25,7 @@ configurations { } test { - systemProperty 'junit.jupiter.execution.parallel.enabled', false + systemProperty 'junit.jupiter.execution.parallel.enabled', true systemProperty 'junit.jupiter.execution.parallel.mode.default', "concurrent" useJUnitPlatform() maxHeapSize = "4g" diff --git a/module-server/src/test/java/de/twomartens/wahlrecht/service/CalculationServiceTest.java b/module-server/src/test/java/de/twomartens/wahlrecht/service/CalculationServiceTest.java index 09ec463..4dcb03e 100644 --- a/module-server/src/test/java/de/twomartens/wahlrecht/service/CalculationServiceTest.java +++ b/module-server/src/test/java/de/twomartens/wahlrecht/service/CalculationServiceTest.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.lang.NonNull; @@ -70,6 +71,12 @@ class CalculationServiceTest { private CalculationService service; + @BeforeAll + static void setUpOverall() { + setUpCandidatesOverall(); + setUpResultsOverall(); + } + @BeforeEach void setService() { service = new CalculationService(); @@ -115,8 +122,6 @@ class CalculationServiceTest { GRUENE_BEZIRK, AFD_BEZIRK ); - setUpCandidatesOverall(); - setUpResultsOverall(); SeatResult result = service.calculateOverallSeatDistribution(election, nominations); @@ -131,8 +136,6 @@ class CalculationServiceTest { @Test void shouldCalculateOverallCandidatesCorrectly() { - setUpCandidatesOverall(); - setUpResultsOverall(); Map seatsPerNomination = Map.of( SPD_BEZIRK, 2, CDU_BEZIRK, 2, @@ -308,7 +311,7 @@ class CalculationServiceTest { .build()); } - private void setUpCandidatesOverall() { + private static void setUpCandidatesOverall() { SPD_BEZIRK.addCandidates(buildCandidates( GOTTLIEB_GABOR, "Meding, Sarah", "Harringa, Nils", "Nendza-Ammar, Charlotte", "Rust, Rüdiger", "Köster-Marjanovic, Hannelore", RIEGEL_ANN_KATHRIN, "Rüter, Monika", @@ -372,7 +375,7 @@ class CalculationServiceTest { )); } - private void setUpResultsOverall() { + private static void setUpResultsOverall() { SPD_BEZIRK.setVotingResult(VotingResult.builder() .votesOnNomination(84703) .votesThroughHealing(985)