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

JUnit: Exception in BeforeAll/AfterAll with TestInfo parameter #19800

Closed
antoniomacri opened this issue Aug 31, 2021 · 3 comments · Fixed by #19809
Closed

JUnit: Exception in BeforeAll/AfterAll with TestInfo parameter #19800

antoniomacri opened this issue Aug 31, 2021 · 3 comments · Fixed by #19809
Assignees
Labels
area/testing kind/bug Something isn't working
Milestone

Comments

@antoniomacri
Copy link

antoniomacri commented Aug 31, 2021

Describe the bug

An exception is thrown on JUnit Before/AfterAll methods:

@QuarkusTest
public class AnnotatedTest {

    @BeforeAll
    public static void beforeAll(TestInfo testInfo) {
        Assertions.assertEquals(AnnotatedTest.class, testInfo.getTestClass().get());
        Assertions.assertFalse(testInfo.getTestMethod().isPresent());
    }

    @Test
    public void testInfoTestCase() {
    }

    @AfterAll
    public static void afterAll(TestInfo testInfo) {
        Assertions.assertEquals(AnnotatedTest.class, testInfo.getTestClass().get());
        Assertions.assertFalse(testInfo.getTestMethod().isPresent());
    }
}

Expected behavior

Above test passes.

Actual behavior

java.util.NoSuchElementException: No value present

	at java.base/java.util.Optional.get(Optional.java:148)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:1041)
        ...

How to Reproduce?

Run the above test.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.1.Final

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

No response

Additional information

Relates to #19751

@geoand
Copy link
Contributor

geoand commented Aug 31, 2021

@famod are you planning on tackling this one?

@quarkus-bot
Copy link

quarkus-bot bot commented Aug 31, 2021

/cc @geoand

@famod famod self-assigned this Aug 31, 2021
@famod famod changed the title JUnit: Exception in BeforeAll/AfterAll JUnit: Exception in BeforeAll/AfterAll with TestInfo parameter Aug 31, 2021
@famod
Copy link
Member

famod commented Aug 31, 2021

@geoand I will: #19482 (comment) 😉

@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Sep 1, 2021
@gsmet gsmet modified the milestones: 2.3 - main, 2.2.2.Final Sep 6, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 6, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 6, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 6, 2021
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.

4 participants