-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Introduce integration test source set for gradle based project #24064
Conversation
cc @edeandrea |
@@ -498,7 +498,7 @@ private static Path determineBuildOutputDirectory(final URL url) { | |||
if (url.getPath().endsWith("test-classes/")) { | |||
// we have the maven test classes dir | |||
return toPath(url).getParent(); | |||
} else if (url.getPath().endsWith("test/")) { | |||
} else if (url.getPath().endsWith("test/") || url.getPath().endsWith("intTest/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check whether what we are doing if url.getPath().endsWith("-tests.jar")
will work for all the other cases. That could be a separate PR though.
@edeandrea is it ok for you? this introduce a new |
intTestTask.dependsOn(quarkusBuild); | ||
intTestTask.setClasspath(intTestSourceSet.getRuntimeClasspath()); | ||
intTestTask.setTestClassesDirs(intTestSourceSet.getOutput().getClassesDirs()); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need intTestTask.setShouldRunAfter(List.of(tasks.findByName(JavaPlugin.TEST_TASK_NAME)));
as well?
---- | ||
|
||
This task depends on `quarkusBuild`. The final artifact will be produced before running tests. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does quarkusBuild
also run the check
task (or at a minimum the test
task)? If so, maybe you should mention that the unit tests will also be executed?
Maybe not necessary, but just a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently quarkusBuild
is not linked to any test
task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it (or the intTest
task) be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a dependency between quarkusIntTest
and check
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.config.inject.ConfigProperty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this import is necessary?
@@ -0,0 +1,20 @@ | |||
package org.acme; | |||
|
|||
import javax.inject.Inject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this import is necessary?
.when().get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.body(is("Hello from Test")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this test passes? ExampleResource
only has a single endpoint, /hello
, which returns "Hello World"
? Am I missing something obvious somewhere?
I see in src/test/resources/application.properties
there are 2 properties, yet ExampleResource.java
never references them.
This leads me to believe that simply running the intTest
task does not trigger the check
task (or at a minimum the test
task). Should it? Should you ever have the case where your integration tests pass yet your unit tests fail?
.when().get("test-only") | ||
.then() | ||
.statusCode(200) | ||
.body(is("Test only")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this test passes? Where is the test-only
endpoint defined? Am I missing something obvious?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it.
public void shouldRunIntegrationTestAsPartOfBuild() throws Exception { | ||
File projectDir = getProjectDir("it-test-basic-project"); | ||
|
||
BuildResult buildResult = runGradleWrapper(projectDir, "clean", "quarkusIntTest"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above re: should the intTest
task trigger the check
(or at a minimum test
) task?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I will add a dependency the check
task.
Is |
Are you talking about the source set name? Personally I think |
There isn't convention for this. |
|
Mkay. Personally, I never saw |
Actually I was just looking at one of my personal projects. I use @gsmet you should use it - it's a far better tool IMO :) |
I updated the task name to match the name of the source set.
@aloubyansky, @geoand do you have a preference ? |
I vote for |
Another thing is, so far, every command in the Quarkus plugin had |
Yes this is a risk. We can make the source set name configurable with a default value of ˋintegrationTest |
I agree - keep it consistent. If every task the plugin introduces has the Personally I like |
I adressed all comments, updated the sourceSet to |
Nice work! |
Hey @glefloch should the Currently it just says
Maybe it should say something like As a test annotated with ? |
Right, I will add a note on this guide. |
Not sure if ' or the quarkusIntTest task if using Gradle.' is the note added. |
This introduce a new
intTest
source set (src/intTest/java
) and a newquarkusIntTest
task that execcute@QuarkusIntegrationTest
.This tasks depends on
quarkusBuild
to make sure the final artifact used by integration test is generated.Next step will be:
intTest
sourceSet instead ofnative-test
nativeTest
task to combine both sourceSetnative-test
sourceSetClose #23528
Close #22035