[
https://issues.apache.org/jira/browse/SUREFIRE-1973?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17466273#comment-17466273
]
Eric Kolotyluk edited comment on SUREFIRE-1973 at 12/29/21, 12:57 AM:
----------------------------------------------------------------------
Under 2.22.2 I see
{code:java}
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - i = 0
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - i = 1
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - i = 2
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = true
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - Interrupted value =
1
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - value =
2
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - count = 3
15:45:38.279 [main] DEBUG net.kolotyluk.loom.LagTests - value = 2
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.582 s
- in net.kolotyluk.loom.LagTests
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS{code}
but under 3.0.0-M5 I see
{code:java}
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 0
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 1
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 2
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = true
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 3
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 4
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 5
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 6
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 7
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 8
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 9
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - count = 10
15:45:38.461 [main] DEBUG net.kolotyluk.loom.LagTests - value = 3
[ERROR] Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.74 s
<<< FAILURE! - in net.kolotyluk.loom.LagTests
[ERROR] net.kolotyluk.loom.LagTests.sleepWithoutInterruptHandler Time elapsed:
0.37 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <2> but was: <3>
at
net.kolotyluk.loom.LagTests.sleepWithoutInterruptHandler(LagTests.java:119)
{code}
So, with only a surefire version change, my test code is not seeing the
Thread.interrupt(); correctly. Also, the thread name should be "Thread-3" not
"Thread-4"
was (Author: kolotyluk):
Under 2.22.2 I see
{code:java}
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - i = 0
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - i = 1
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - i = 2
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = true
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - Interrupted value =
1
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - value =
2
15:45:38.279 [Thread-3] DEBUG net.kolotyluk.loom.LagTests - count = 3
15:45:38.279 [main] DEBUG net.kolotyluk.loom.LagTests - value = 2
Process finished with exit code 0 {code}
but under 3.0.0-M5 I see
{code:java}
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 0
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 1
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 2
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = true
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 3
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 4
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 5
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 6
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 7
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 8
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - i = 9
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests -
Thread.currentThread().isInterrupted() = false
15:45:38.461 [Thread-4] DEBUG net.kolotyluk.loom.LagTests - count = 10
15:45:38.461 [main] DEBUG net.kolotyluk.loom.LagTests - value = 3
[ERROR] Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.74 s
<<< FAILURE! - in net.kolotyluk.loom.LagTests
[ERROR] net.kolotyluk.loom.LagTests.sleepWithoutInterruptHandler Time elapsed:
0.37 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <2> but was: <3>
at
net.kolotyluk.loom.LagTests.sleepWithoutInterruptHandler(LagTests.java:119)
{code}
So, with only a surefire version change, my test code is not seeing the
Thread.interrupt(); correctly. Also, the thread name should be "Thread-3" not
"Thread-4"
> Tests Fail in 3.0.0-M5 but Pass in 2.22.2
> -----------------------------------------
>
> Key: SUREFIRE-1973
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1973
> Project: Maven Surefire
> Issue Type: Bug
> Components: Maven Surefire Plugin
> Affects Versions: 3.0.0-M5
> Environment: https://github.com/kolotyluk/loom-lab
> (laboratory/LagTests)
> Windows 10, Java 17, IntelliJ IDEA 2021.3
> Build #IU-213.5744.223, built on November 27, 2021
> Runtime version: 11.0.13+7-b1751.19 amd64
> VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
> Reporter: Eric Kolotyluk
> Priority: Major
> Fix For: waiting-for-feedback
>
>
> I have some unit tests that are failing when I run `mvn test` but pass when I
> run them from the IntelliJ IDEA User Interface.
> The same tests pass when I use `2.22.2` of the Surefire Plugin with `mvn
> test`.
> I am not sure what other information is helpful, but you can clone the
> project from GitHub to see the issue in action. I would be happy to provide
> more specific information on request.
> _It is particularly odd that the test code actually behaves differently when
> running with Surefire 3.0.0-M5, which I would not have thought possible._
--
This message was sent by Atlassian Jira
(v8.20.1#820001)