1212import java .util .List ;
1313import java .util .Set ;
1414import java .util .function .Supplier ;
15- import java .util .logging .Level ;
16- import java .util .logging .Logger ;
1715import java .util .regex .Pattern ;
1816
1917import static org .assertj .core .api .Assertions .assertThat ;
2018
2119@ TestInstance (TestInstance .Lifecycle .PER_CLASS )
2220public class BaseFakerTest <T extends BaseFaker > {
2321
24- private static final Logger LOG = Logger .getLogger (BaseFakerTest .class .getCanonicalName ());
2522 protected T faker = getFaker ();
2623
2724 @ BeforeEach
@@ -46,14 +43,9 @@ protected List<String> getBaseList(String key) {
4643 return faker .fakeValuesService ().fetchObject (key , faker .getContext ());
4744 }
4845
49- @ ParameterizedTest (name = "{0}" )
46+ @ ParameterizedTest (name = "{0}" , allowZeroInvocations = true )
5047 @ MethodSource ("providerListTest" )
5148 protected void testProviderList (TestSpec testSpec , TestInfo testInfo ) {
52- if (testSpec .isDummy ) {
53- // skip and log dummy
54- LOG .log (Level .WARNING , "Dummy test for " + testInfo .getTestClass ().get ());
55- return ;
56- }
5749 // Given
5850 Set <String > actual = new HashSet <>(getBaseList (testSpec .key ));
5951 // When
@@ -69,13 +61,9 @@ protected void testProviderList(TestSpec testSpec, TestInfo testInfo) {
6961 }
7062 }
7163
72- @ ParameterizedTest
64+ @ ParameterizedTest ( allowZeroInvocations = true )
7365 @ MethodSource ("providerListTest" )
7466 void testNoDuplications (TestSpec testSpec ) {
75- if (testSpec .isDummy ) {
76- return ;
77- }
78-
7967 var terms = getBaseList (testSpec .key );
8068
8169 Set <String > uniques = new HashSet <>();
@@ -91,21 +79,18 @@ void testNoDuplications(TestSpec testSpec) {
9179 }
9280
9381 protected Collection <TestSpec > providerListTest () {
94- // dummy test since parameterized test requires non-empty collection
95- return Set .of (new TestSpec (null , null , null ));
82+ return Set .of ();
9683 }
9784
9885 protected static class TestSpec {
9986 private final Supplier <?> supplier ;
10087 private final String key ;
101- private final boolean isDummy ;
10288 @ SuppressWarnings ("unused" )
10389 private final String regex ;
10490
10591 private TestSpec (Supplier <?> supplier , String key , String regex ) {
10692 this .supplier = supplier ;
10793 this .key = key ;
108- this .isDummy = key == null || supplier == null ;
10994 this .regex = regex ;
11095 }
11196
0 commit comments