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

@QuarkusMain not called from @QuarkusTest #19957

Closed
JanM-cz opened this issue Sep 7, 2021 · 4 comments
Closed

@QuarkusMain not called from @QuarkusTest #19957

JanM-cz opened this issue Sep 7, 2021 · 4 comments
Labels
area/testing env/windows Impacts Windows machines kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant

Comments

@JanM-cz
Copy link

JanM-cz commented Sep 7, 2021

Describe the bug

When @QuarkusTest is executed in combination with @QuarkusMain definition, the main class is not being called, but neither is the default configuration context which is normally executed when no @QuarkusMain is defined. This results in "underconfigured" system.

This prevents proper usage of @QuarkusMain for any customizations because they are then not available during @QuarkusTest context. One example would be apache-camel integration when routes are not being registered in such setup, but it seems to be a generic problem.

Expected behavior

@QuarkusMain annotated class is executed on application startup when @QuarkusTest is being executed.

Actual behavior

@QuarkusMain class is not being executed at all.

How to Reproduce?

I've setup a simple apache camel-timer based reproducer to see that neither the default context nor @QuarkusMain context is being properly configured in @QuarkusTest tests.

To reproduce simply uncomment the @QuarkusMain annotation on MainQuark class and execute the test in TimerRouteTest.

You can observe that:

  1. when the application is started normally -> route is being processed and everything works.
  2. when @QuarkusMain is commented out and test is executed -> route is being processed and everything works.
  3. when @QuarkusMain comment is removed (annotation is activated) and test is executed -> route is not being configured and is not being executed

mainquark.zip

Output of uname -a or ver

Microsoft Windows [Version 10.0.19043.1165]

Output of java -version

openjdk version "11" 2018-09-25

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.1.3.Final

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

Apache Maven 3.8.1

Additional information

No response

@JanM-cz JanM-cz added the kind/bug Something isn't working label Sep 7, 2021
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Sep 7, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 7, 2021

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Sep 7, 2021

@stuartwdouglas I assume that #19891 should cover this, right?

@ebullient
Copy link
Member

ebullient commented Sep 7, 2021

Yes. #19891 is specifically to address testing of QuarkusMain applications. 🎉

Docs have been updated (will show up under the main branch). Until then, information for how to use the new test annotations is here: https://github.com/stuartwdouglas/quarkus/blob/c3baf659b0b0b0bcf733d774455f51e97a671ae6/docs/src/main/asciidoc/command-mode-reference.adoc

@geoand
Copy link
Contributor

geoand commented Sep 7, 2021

Excellent 👌🏼 .

So I'll close this as out of date.

@geoand geoand added the triage/out-of-date This issue/PR is no longer valid or relevant label Sep 7, 2021
@geoand geoand closed this as completed Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing env/windows Impacts Windows machines kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant
Projects
None yet
Development

No branches or pull requests

4 participants