Skip to content

Add test for @ParameterizedClass #722

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

Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.graalvm.junit.jupiter;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.ValueSource;

abstract class BaseTests {
@Test
void test(TestInfo testInfo) {
Assertions.assertEquals(ParameterizedClassTests.InnerTests.class, testInfo.getTestClass().orElseThrow());
}
}

@ParameterizedClass
@ValueSource(ints = { 1, 2 })
class ParameterizedClassTests {

private final int value;

ParameterizedClassTests(int value) {
this.value = value;
}

@Test
void test() {
Assertions.assertTrue(value == 1 || value == 2);
}

@Nested
class InnerTests extends BaseTests {
}
}
1 change: 1 addition & 0 deletions common/utils/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ dependencies {
implementation(libs.openjson)
testImplementation(platform(libs.test.junit.bom))
testImplementation(libs.test.junit.jupiter.core)
testRuntimeOnly(libs.test.junit.platform.launcher)
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ mavenEmbedder = "3.9.9"
mavenResolver = "1.9.22"
graalvm = "23.0.2"
openjson = "1.0.13"
junitPlatform = "1.11.0"
junitJupiter = "5.11.0"
junitPlatform = "1.13.0-M3"
junitJupiter = "5.13.0-M3"
slf4j = "1.7.9"
groovy = "3.0.11"
jetty = "11.0.11"
Expand Down
5 changes: 2 additions & 3 deletions samples/junit-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ repositories {
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.0'
testImplementation "org.junit.vintage:junit-vintage-engine:5.11.0"
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.0-M3'
testImplementation "org.junit.vintage:junit-vintage-engine:5.13.0-M3"
}

application {
Expand All @@ -62,4 +62,3 @@ tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

2 changes: 1 addition & 1 deletion samples/junit-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.jupiter.version>5.11.0</junit.jupiter.version>
<junit.jupiter.version>5.13.0-M3</junit.jupiter.version>
<native.maven.plugin.version>0.10.7-SNAPSHOT</native.maven.plugin.version>
<junit.platform.native.version>0.10.7-SNAPSHOT</junit.platform.native.version>
<imageName>example-app</imageName>
Expand Down