-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24935 from Sgitario/fix_test_profile_nested
Support @testprofile when using @nested tests
- Loading branch information
Showing
2 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
...tests/main/src/test/java/io/quarkus/it/main/QuarkusTestNestedWithTestProfileTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package io.quarkus.it.main; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
import io.quarkus.test.junit.TestProfile; | ||
import io.restassured.RestAssured; | ||
|
||
@QuarkusTest | ||
@Tag("nested") | ||
@TestProfile(QuarkusTestNestedWithTestProfileTestCase.OuterProfile.class) | ||
public class QuarkusTestNestedWithTestProfileTestCase { | ||
|
||
private static final int TEST_PORT_FROM_PROFILE = 7777; | ||
|
||
@Nested | ||
class NestedCase { | ||
|
||
@Test | ||
void testProfileFromNested() { | ||
Assertions.assertEquals(TEST_PORT_FROM_PROFILE, RestAssured.port); | ||
RestAssured.when() | ||
.get("/greeting/Stu") | ||
.then() | ||
.statusCode(200) | ||
.body(is("OuterProfile Stu")); | ||
} | ||
} | ||
|
||
@Nested | ||
@TestProfile(QuarkusTestNestedWithTestProfileTestCase.ModernEnglishProfile.class) | ||
class ModernEnglishCase { | ||
|
||
@Test | ||
void testProfileFromNested() { | ||
RestAssured.when() | ||
.get("/greeting/Stu") | ||
.then() | ||
.statusCode(200) | ||
.body(is("Hey Stu")); | ||
} | ||
} | ||
|
||
public static class OuterProfile implements QuarkusTestProfile { | ||
|
||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Collections.singletonMap("quarkus.http.test-port", "" + TEST_PORT_FROM_PROFILE); | ||
} | ||
|
||
@Override | ||
public String[] commandLineParameters() { | ||
return new String[] { "OuterProfile" }; | ||
} | ||
|
||
@Override | ||
public boolean runMainMethod() { | ||
return true; | ||
} | ||
} | ||
|
||
public static class ModernEnglishProfile implements QuarkusTestProfile { | ||
|
||
@Override | ||
public String[] commandLineParameters() { | ||
return new String[] { "Hey" }; | ||
} | ||
|
||
@Override | ||
public boolean runMainMethod() { | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters