Skip to content

Commit

Permalink
Polish test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Sep 12, 2024
1 parent 65aa610 commit 9f5cfc9
Showing 1 changed file with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,24 @@
package org.junit.platform.engine.support.hierarchical;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.commons.JUnitException;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class ForkJoinPoolHierarchicalTestExecutorServiceTests {

@Mock
ParallelExecutionConfiguration configuration;

@Test
void exceptionsFromInvalidConfigurationAreNotSwallowed() {
when(configuration.getParallelism()).thenReturn(2);
when(configuration.getMaxPoolSize()).thenReturn(1); // invalid, should be > parallelism
when(configuration.getCorePoolSize()).thenReturn(1);
when(configuration.getMinimumRunnable()).thenReturn(1);
when(configuration.getSaturatePredicate()).thenReturn(__ -> true);
when(configuration.getKeepAliveSeconds()).thenReturn(0);

JUnitException exception = assertThrows(JUnitException.class,
() -> new ForkJoinPoolHierarchicalTestExecutorService(configuration));
var configuration = new DefaultParallelExecutionConfiguration(2, 1, 1, 1, 0, __ -> true);

JUnitException exception = assertThrows(JUnitException.class, () -> {
try (var pool = new ForkJoinPoolHierarchicalTestExecutorService(configuration)) {
assertNotNull(pool, "we won't get here");
}
});

assertThat(exception).hasMessage("Failed to create ForkJoinPool");
assertThat(exception).rootCause().isInstanceOf(IllegalArgumentException.class);
}
Expand Down

0 comments on commit 9f5cfc9

Please sign in to comment.