Skip to content

Commit

Permalink
add test case for parameterized tests without explicit source
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Coles committed Jan 3, 2023
1 parent acb6406 commit 67f77ae
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Expand Up @@ -20,6 +20,7 @@

import org.junit.jupiter.api.Test;
import org.pitest.junit5.cucumber.RunCucumberTest;
import org.pitest.junit5.repository.ParameterizedNoExplicitSource;
import org.pitest.junit5.repository.TestClassWithFailingTest;
import org.pitest.junit5.repository.TestClassWithIncludedTestMethod;
import org.pitest.junit5.repository.TestClassWithInheritedTestMethod;
Expand Down Expand Up @@ -100,9 +101,15 @@ void detectsErroringTestsWhenPassingTestsPresent() {

@Test
void findsAndRunsParameterizedTests() {
findsAndRunsNTests(2, TestClassWithParameterizedTestAnnotation.class);
findsAndRunsNTests(4, TestClassWithParameterizedTestAnnotation.class);
}

@Test
void findsAndRunsParameterizedTestsWithoutExplicitMethodSource() {
findsAndRunsNTests(2, ParameterizedNoExplicitSource.class);
}


@Test
void findsAndRunsTestsWithRepeatedATestAnnotation() {
findsAndRunsNTests(1, TestClassWithRepeatedTestAnnotation.class);
Expand Down
@@ -0,0 +1,19 @@
package org.pitest.junit5.repository;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.stream.Stream;

public class ParameterizedNoExplicitSource {

@ParameterizedTest
@MethodSource()
public void parameterizedTest(String string) {

}

static Stream<String> parameterizedTest() {
return Stream.of("foo", "bar");
}
}
Expand Up @@ -27,9 +27,9 @@
public class TestClassWithParameterizedTestAnnotation {

@ParameterizedTest
@ValueSource(strings = {"foo"})
@ValueSource(strings = {"hello", "goodbye"})
public void parameterizedTest(String string) {

}

@ParameterizedTest
Expand All @@ -39,6 +39,6 @@ public void methodParameterizedTest(String string) {
}

static Stream<Arguments> someMethod() {
return Stream.of(Arguments.of("foo"));
return Stream.of(Arguments.of("foo"), Arguments.of("bar"));
}
}

0 comments on commit 67f77ae

Please sign in to comment.