Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Nested JUnit test doesn't inherit lifecycle of @QuarkusTest #20114

Closed
Foobartender opened this issue Sep 13, 2021 · 3 comments · Fixed by #24172
Closed

@Nested JUnit test doesn't inherit lifecycle of @QuarkusTest #20114

Foobartender opened this issue Sep 13, 2021 · 3 comments · Fixed by #24172
Labels
area/testing kind/bug Something isn't working
Milestone

Comments

@Foobartender
Copy link
Contributor

Foobartender commented Sep 13, 2021

Describe the bug

@Nested test of a test annotated with @QuarkusTest and @TestInstance(TestInstance.Lifecycle.PER_CLASS) is run with a new instance of its outer test.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

  1. Run the test below. It passes.
  2. Annotate it with @QuarkusTest and run it again. The outer test passes, but the nested test fails.
// @QuarkusTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@TestMethodOrder(MethodOrderer.OrderAnnotation::class)
class TestLifecycle {
 var s: String? = null

 @Test
 @Order(1)
 fun setString() {
  s = "foo"
 }

 @Test
 @Order(2)
 fun testString() {
  assertEquals("foo", s)
 }


 @Nested
 inner class NestedTest {
  @Test
  fun testString() {
   assertEquals("foo", s)
  }
 }
}

Edit: same test in Java, makes no difference.

// @QuarkusTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class TestLifecycleJ {
 private String s;


 @Test
 @Order(1)
 public void setString() {
  s="foo";
 }


 @Test
 @Order(2)
 public void testString() {
  assertEquals("foo", s);
 }


 @Nested
 public class NestedTest {
  @Test
  public void testString() {
   assertEquals("foo", s);
  }
 }
}

Output of uname -a or ver

Linux ***** 5.14.2-arch1-2 #1 SMP PREEMPT Thu, 09 Sep 2021 09:42:35 +0000 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment GraalVM CE 21.2.0 (build 11.0.12+6-jvmci-21.2-b08) OpenJDK 64-Bit Server VM GraalVM CE 21.2.0 (build 11.0.12+6-jvmci-21.2-b08, mixed mode, sharing)

GraalVM version (if different from Java)

21.2.0

Quarkus version or git rev

2.2.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 7.2

Additional information

No response

@Foobartender Foobartender added the kind/bug Something isn't working label Sep 13, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 13, 2021

/cc @evanchooly

@Sgitario
Copy link
Contributor

Sgitario commented Mar 9, 2022

@geoand I've just realized this issue is also fixed as part of #24172

@geoand
Copy link
Contributor

geoand commented Mar 9, 2022

Cool

@geoand geoand closed this as completed Mar 9, 2022
@geoand geoand added this to the 2.8 - main milestone Mar 9, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.5.Final Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants