aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2017-03-23 15:33:37 +0000
committerPaul Duffin <paulduffin@google.com>2017-03-24 11:45:30 +0000
commitab5f9f1d788a2cc59ae0e6b18d527a4f1acd5563 (patch)
treef709289deffa11c315718fd7f30b9ed3493aef6c
parent99fe7c3891c8a9600d9b568ff50f3e25863d6108 (diff)
downloadjunit-params-ab5f9f1d788a2cc59ae0e6b18d527a4f1acd5563.tar.gz
Hard code text case name template for AndroidJUnitRunner and CTS
AndroidJUnitRunner and CTS require test names to be a specific format. The default JUnitParams format is not suitable. This change forces it to one that is suitable and prevents it from being overridden using the @TestCaseName annotation. These are a sample of parameterized and unparameterized test names. The latter two are from a JUnitParamsRunner based test. libcore.java.net.FtpURLConnectionTest#testOutputUrl pass libcore.java.net.IDNTest#test_toUnicode_failures pass libcore.java.net.InetAddressTest#test_getByName_invalid[0] pass libcore.java.net.InetAddressTest#test_getByName_invalid[1] pass Bug: 36074730 Bug: 36541809 Test: run cts -m CtsLibcoreTestCases and check test names of parameterized tests, e.g. those from libcore.java.net.InetAddressTest Change-Id: Id9a8f8ce9affeb85fb2f410d11e764e99d7287b3
-rw-r--r--src/main/java/junitparams/naming/MacroSubstitutionNamingStrategy.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/junitparams/naming/MacroSubstitutionNamingStrategy.java b/src/main/java/junitparams/naming/MacroSubstitutionNamingStrategy.java
index ce56847..1bdcafb 100644
--- a/src/main/java/junitparams/naming/MacroSubstitutionNamingStrategy.java
+++ b/src/main/java/junitparams/naming/MacroSubstitutionNamingStrategy.java
@@ -14,7 +14,9 @@ public class MacroSubstitutionNamingStrategy implements TestCaseNamingStrategy {
private static final Pattern MACRO_SPLIT_PATTERN = Pattern.compile(String.format("(?=%s)|(?<=%s)", MACRO_PATTERN, MACRO_PATTERN));
private static final String MACRO_START = "{";
private static final String MACRO_END = "}";
- static final String DEFAULT_TEMPLATE = "[{index}] {params} ({method})";
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names, changing
+ // them will prevent CTS and AndroidJUnitRunner from working properly; see b/36541809
+ static final String DEFAULT_TEMPLATE = "{method}[{index}]";
private TestMethod method;
public MacroSubstitutionNamingStrategy(TestMethod testMethod) {
@@ -37,7 +39,12 @@ public class MacroSubstitutionNamingStrategy implements TestCaseNamingStrategy {
private String getTemplate(TestCaseName testCaseName) {
if (testCaseName != null) {
- return testCaseName.value();
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names,
+ // changing them will prevent CTS and AndroidJUnitRunner from working properly;
+ // see b/36541809
+ throw new IllegalStateException(
+ "@TestCaseName not currently supported as it breaks running tests in CTS");
+ // return testCaseName.value();
}
return DEFAULT_TEMPLATE;