Skip to content

Commit

Permalink
Document how to use QuarkusTestProfile#testResources
Browse files Browse the repository at this point in the history
Fixes: #12081
  • Loading branch information
geoand committed Sep 14, 2020
1 parent 6984fea commit 306d5c8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/src/main/asciidoc/getting-started-testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ import java.util.Map;
import java.util.Set;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.QuarkusTestProfile.TestResourceEntry;
public class MockGreetingProfile implements QuarkusTestProfile {
Expand All @@ -504,11 +505,19 @@ public class MockGreetingProfile implements QuarkusTestProfile {
public String getConfigProfile() { <3>
return "test";
}
@Override
public List<TestResourceEntry> testResources() { <4>
return Collections.singletonList(new TestResourceEntry(CustomWireMockServerManager.class));
}
}
----
<1> This method allows us to override configuration properties. Here we are changing the JAX-RS root path.
<2> This method allows us to enable CDI `@Alternative` beans. This makes it easy to mock out certain beans functionality.
<3> This can be used to change the config profile. As this default is `test` this does nothing, but is included for completeness.
<4> This method allows us to apply **additional** `QuarkusTestResourceLifecycleManager` classes, specific for this profile only. If this
method is not overridden, then only the `QuarkusTestResourceLifecycleManager` classes enabled via the `@QuarkusTestResource` class
annotation will be used for the tests using this profile (which is the same behavior as tests that don't use a profile at all).

Now we have defined our profile we need to include it on our test class. We do this with `@TestProfile(MockGreetingProfile.class)`.

Expand Down

0 comments on commit 306d5c8

Please sign in to comment.