Skip to content

Commit

Permalink
inlined annotation for dataprovider using FrameworkMethod (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaschmid committed Jul 7, 2014
1 parent 214b3ec commit dfa0e61
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -213,17 +217,14 @@ public void testStringLength2(String str, int expectedLength) {
"1, DOWN",
"3, FLOOR",
})
// @formatter:off
// @formatter:on
public void testOldModeToRoundingMode(int oldMode, RoundingMode expected) {
// Expect:
assertThat(RoundingMode.valueOf(oldMode)).isEqualTo(expected);
}

@Test
@DataProvider({
"null",
"",
})
@DataProvider({ "null", "", })
public void testIsEmptyString2(String str) {
// When:
boolean isEmpty = (str == null) ? true : str.isEmpty();
Expand All @@ -232,9 +233,23 @@ public void testIsEmptyString2(String str) {
assertThat(isEmpty).isTrue();
}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ExternalFile {
public enum Format {
CSV,
XML,
XLS;
}

Format format();
String value();
}

@DataProvider
public static Object[][] loadFromExternalFile(FrameworkMethod testMethod) {
String testDataFile = testMethod.getAnnotation(ExternalFile.class).value();
// Load the data from the external file here ...
return new Object[][] { { testDataFile } };
}

Expand Down

This file was deleted.

0 comments on commit dfa0e61

Please sign in to comment.