-
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.
QuarkusComponentTest: support parameterized test methods
- arguments of a parameterized test method that are provided by an ArgumentsProvider must be annotated with SkipInject
- Loading branch information
Showing
5 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
47 changes: 47 additions & 0 deletions
47
.../test/java/io/quarkus/test/component/paraminject/ParameterInjectionParameterizedTest.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,47 @@ | ||
package io.quarkus.test.component.paraminject; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import jakarta.annotation.PreDestroy; | ||
import jakarta.enterprise.context.Dependent; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import io.quarkus.test.component.QuarkusComponentTest; | ||
import io.quarkus.test.component.SkipInject; | ||
|
||
@QuarkusComponentTest | ||
public class ParameterInjectionParameterizedTest { | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { "alpha", "bravo", "delta" }) | ||
public void testParamsInjection(@SkipInject String param, Converter converter) { | ||
Assertions.assertThat(converter.convert(param)).isIn("ALPHA", "BRAVO", "DELTA"); | ||
} | ||
|
||
@AfterAll | ||
public static void afterAll() { | ||
assertEquals(3, Converter.DESTROYED.get()); | ||
} | ||
|
||
@Dependent | ||
public static class Converter { | ||
|
||
static final AtomicInteger DESTROYED = new AtomicInteger(); | ||
|
||
String convert(String param) { | ||
return param.toUpperCase(); | ||
} | ||
|
||
@PreDestroy | ||
void destroy() { | ||
DESTROYED.incrementAndGet(); | ||
} | ||
} | ||
|
||
} |