-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support to specify a test name formatter on @dataProvider annotation (#…
…101) Signed-off-by: Andreas Schmid <service@aaschmid.de>
- Loading branch information
Showing
9 changed files
with
104 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...src/main/java/com/tngtech/junit/dataprovider/format/DataProviderPlaceholderFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.tngtech.junit.dataprovider.format; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.List; | ||
|
||
import com.tngtech.junit.dataprovider.placeholder.BasePlaceholder; | ||
import com.tngtech.junit.dataprovider.placeholder.ReplacementData; | ||
|
||
public class DataProviderPlaceholderFormatter implements DataProviderTestNameFormatter { | ||
|
||
private final String format; | ||
private final List<? extends BasePlaceholder> placeholders; | ||
|
||
public DataProviderPlaceholderFormatter(String format, List<? extends BasePlaceholder> placeholders) { | ||
this.format = format; | ||
this.placeholders = placeholders; | ||
} | ||
|
||
@Override | ||
public String format(Method testMethod, int invocationIndex, List<Object> arguments) { | ||
ReplacementData data = ReplacementData.of(testMethod, invocationIndex, arguments); | ||
|
||
String result = format; | ||
for (BasePlaceholder placeHolder : placeholders) { | ||
result = placeHolder.process(data, result); | ||
} | ||
return result; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...er/src/main/java/com/tngtech/junit/dataprovider/format/DataProviderTestNameFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.tngtech.junit.dataprovider.format; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.List; | ||
|
||
public interface DataProviderTestNameFormatter { | ||
|
||
String format(Method testMethod, int invocationIndex, List<Object> arguments); | ||
} |