@Test public void testGenerateLocationsShouldReturnTestClassIfExplicitLocationsAreNull() throws Exception { // Given: Class<?>[] explicitLocations = null; // When: List<Class<?>> result = DataProviderResolverContext.generateLocations(this.getClass(), explicitLocations); // Then: assertThat(result).containsOnly(this.getClass()); }
@Test public void testGenerateLocationsShouldReturnTestClassIfExplicitLocationsAreEmpty() throws Exception { // Given: Class<?>[] explicitLocations = {}; // When: List<Class<?>> result = DataProviderResolverContext.generateLocations(this.getClass(), explicitLocations); // Then: assertThat(result).containsOnly(this.getClass()); }
@Test public void testGenerateLocationsShouldReturnExplicitLocationsIfNotNull() throws Exception { // Given: Class<?>[] explicitLocations = { SingleArgConverter.class, StringConverter.class }; // When: List<Class<?>> result = DataProviderResolverContext.generateLocations(this.getClass(), explicitLocations); // Then: assertThat(result).containsExactly(explicitLocations); }
@Override protected DataProviderResolverContext getDataProviderResolverContext(ExtensionContext extensionContext, UseDataProvider testAnnotation) { return new DataProviderResolverContext(extensionContext.getRequiredTestMethod(), asList(sourceAnnotation.resolver()), sourceAnnotation.resolveStrategy(), generateLocations(extensionContext.getRequiredTestClass(), sourceAnnotation.location()), DataProvider.class, sourceAnnotation.value()); }
@Override protected DataProviderResolverContext getDataProviderResolverContext(ExtensionContext extensionContext, UseDataProvider testAnnotation) { return new DataProviderResolverContext(extensionContext.getRequiredTestMethod(), asList(testAnnotation.resolver()), testAnnotation.resolveStrategy(), generateLocations(extensionContext.getRequiredTestClass(), testAnnotation.location()), DataProvider.class, testAnnotation.value()); }
@Test public void testGenerateLocationsShouldThrowNullPointerExceptionIfTestClassIsNull() throws Exception { // Given: expectedException.expect(NullPointerException.class); expectedException.expectMessage("'testClass' must not be null"); // When: DataProviderResolverContext.generateLocations(null); // Then: expect exception }