[
https://issues.apache.org/jira/browse/SUREFIRE-2217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17796687#comment-17796687
]
Lukasz Osipiuk commented on SUREFIRE-2217:
------------------------------------------
Yeah - running without concurrency is fine. I tested out with:
TestSurefireBase.java:
{code:java}
package io.trino.abc;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;
import java.util.concurrent.ThreadLocalRandom;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT;
@TestInstance(PER_CLASS)
@Execution(CONCURRENT)
public abstract class TestSurefireBase
{
public TestSurefireBase() {
}
@Test
void testA()
throws InterruptedException
{
Thread.sleep(ThreadLocalRandom.current().nextLong(2000));
}
@Test
void testB()
throws InterruptedException
{
Thread.sleep(ThreadLocalRandom.current().nextLong(2000));
}
@Test
void testC()
throws InterruptedException
{
Thread.sleep(ThreadLocalRandom.current().nextLong(2000));
}
@Test
void testD()
throws InterruptedException
{
Thread.sleep(ThreadLocalRandom.current().nextLong(2000));
}
}
{code}
TestSurefireX.java
{code:java}
package io.trino.abc;
import org.junit.jupiter.api.parallel.Isolated;
public class TestSurefireX
extends TestSurefireBase
{
} {code}
TestSurefireY.java
{code:java}
package io.trino.abc;
import org.junit.jupiter.api.parallel.Isolated;
public class TestSurefireY
extends TestSurefireBase
{
} {code}
{{mvn test -pl :trino-tests -Dtest=TestSurefireX,TestSurefireY}}
yields:
{code:java}
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
2023-12-14T05:29:51.218-0600 INFO ForkJoinPool-1-worker-1
io.airlift.log.Logging Logging to stderr
[INFO] Running io.trino.abc.TestSurefireX
[INFO] Running io.trino.abc.TestSurefireY
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.362 s
-- in io.trino.abc.TestSurefireY
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.820 s
-- in io.trino.abc.TestSurefireX
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0 {code}
If I annotate TestSurefireX and TestSurefireY with @Isolated
then I get:
{code:java}
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
2023-12-14T05:29:31.925-0600 INFO ForkJoinPool-1-worker-1
io.airlift.log.Logging Logging to stderr
[INFO] Running io.trino.abc.TestSurefireY
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.589 s
-- in io.trino.abc.TestSurefireY
[INFO] Running io.trino.abc.TestSurefireX
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.173 s
-- in io.trino.abc.TestSurefireX
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0 {code}
> Surefire wrongly reports number of Junit tests run for test classes with
> common base class
> ------------------------------------------------------------------------------------------
>
> Key: SUREFIRE-2217
> URL: https://issues.apache.org/jira/browse/SUREFIRE-2217
> Project: Maven Surefire
> Issue Type: Bug
> Reporter: Lukasz Osipiuk
> Priority: Minor
>
> Surefire wrongly reports number of Junit tests run for test classes with
> common base class when subclasses are run concurrently.
> It looks like when first test class completes surefire reports the number of
> tests which have been run which is sum of tests run so far from both
> subclasses.
>
> Observed in trinodb/trino. See this issue:
> [https://github.com/trinodb/trino/issues/19908]
>
> cc: [~findepi] [~martint]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)