Skip to content

Commit

Permalink
formatting of pull request #28
Browse files Browse the repository at this point in the history
  • Loading branch information
aaschmid committed Jul 7, 2014
1 parent eea5327 commit 129dcb4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public class DataProviderRunner extends BlockJUnit4ClassRunner {
*/
TestGenerator testGenerator;


/**
* Cached result of {@link #computeTestMethods()}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public List<FrameworkMethod> generateExplodedTestMethodsFor(FrameworkMethod test
List<FrameworkMethod> explodeTestMethod(FrameworkMethod testMethod, FrameworkMethod dataProviderMethod) {
Object data;
try {
Class<?>[] parameterTypes = dataProviderMethod.getMethod().getParameterTypes();
if (parameterTypes.length > 0) {
data = dataProviderMethod.invokeExplosively(null, testMethod);
} else {
data = dataProviderMethod.invokeExplosively(null);
}
Class<?>[] parameterTypes = dataProviderMethod.getMethod().getParameterTypes();
if (parameterTypes.length > 0) {
data = dataProviderMethod.invokeExplosively(null, testMethod);
} else {
data = dataProviderMethod.invokeExplosively(null);
}
} catch (Throwable t) {
throw new Error(String.format("Exception while invoking data provider method '%s': %s",
dataProviderMethod.getName(), t.getMessage()), t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.FrameworkMethod;

import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.java.junit.dataprovider.UseDataProvider;
import org.junit.runners.model.FrameworkMethod;

@RunWith(DataProviderRunner.class)
public class DataProviderJavaAcceptanceTest {
Expand Down Expand Up @@ -232,18 +232,17 @@ public void testIsEmptyString2(String str) {
assertThat(isEmpty).isTrue();
}

@DataProvider
public static Object[][] loadFromExternalFile(FrameworkMethod testMethod) {
String testDataFile = testMethod.getAnnotation(ExternalFile.class).value();
return new Object[][] { { testDataFile } };
}

@Test
@UseDataProvider("loadFromExternalFile")
@ExternalFile(format = ExternalFile.Format.CSV, value = "testdata.csv")
public void testThatUsesUniversalDataProvider(String testData) {
// Expect:
assertThat(testData).isEqualTo("testdata.csv");
}

@DataProvider
public static Object[][] loadFromExternalFile(FrameworkMethod testMethod) {
String testDataFile = testMethod.getAnnotation(ExternalFile.class).value();
return new Object[][]{
{ testDataFile }
};
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package com.tngtech.test.java.junit.dataprovider;

import java.lang.annotation.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ExternalFile {

public enum Format {
CSV, XML, XLS
}
public enum Format {
CSV,
XML,
XLS
}

Format format();
String value();
Format format();

String value();
}

0 comments on commit 129dcb4

Please sign in to comment.