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

Coverage for mixing @QuarkusMainTest and @QuarkusTest in the same package #979

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lifecycle-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</activation>
<properties>
<!-- please keep Mandrel and RHBQ version compatible -->
<quarkus.platform.version>2.13.4.Final</quarkus.platform.version>
<quarkus.platform.version>2.13.6.Final</quarkus.platform.version>
</properties>
<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ private Main() {

public static void main(String... args) {
LOG.info(ARGUMENTS_FROM_MAIN + String.join(",", args));
Quarkus.run(args);
if (args.length > 0 && "cli".equals(args[0])) {
return;
} else {
Quarkus.run(args);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.quarkus.ts.lifecycle;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

/**
* The name of the test is crucial to make it run before HelloMainTest.
* See comments to the issue for the explanation.
*/
@QuarkusTest
@Tag("QUARKUS-2789")
public class AlphabeticallyFirstTest {
fedinskiy marked this conversation as resolved.
Show resolved Hide resolved

@Test
public void shouldBeOk() {
given()
.when().get("/args")
.then()
.statusCode(200)
.body(is(""));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.quarkus.ts.lifecycle;

import java.util.List;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.main.Launch;
import io.quarkus.test.junit.main.LaunchResult;
import io.quarkus.test.junit.main.QuarkusMainTest;

@QuarkusMainTest
public class HelloMainTest {

@Test
@Launch({ "cli", "Hello", "World" })
public void annotatedLaunch(LaunchResult result) {
List<String> outputStream = result.getOutputStream();
String args = null;
for (String output : outputStream) {
if (output.contains("Received arguments:")) {
args = output;
}
}
Assertions.assertNotNull(args);
Assertions.assertTrue(args.contains("Hello"), "No 'Hello' in the output!");
Assertions.assertTrue(args.contains("World"), "No 'World' in the output!");
}
}