aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tb3
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-02-20 22:56:43 +0200
committerVaadin Code Review <review@vaadin.com>2014-03-17 06:43:24 +0000
commit5441ef061e4b3bf1f6545f829121bcefcb256ef9 (patch)
tree3ff9a89afb70270fe7f6a53e393c8b61a6b0dc19 /uitest/src/com/vaadin/tests/tb3
parent0c7cbc73dba97ad0b95cb11f4b4eabb37046fe61 (diff)
downloadvaadin-framework-5441ef061e4b3bf1f6545f829121bcefcb256ef9.tar.gz
vaadin-framework-5441ef061e4b3bf1f6545f829121bcefcb256ef9.zip
Merged IntegrationTestRunner into TB3Runner
Change-Id: I9e14a75b8446623d8995ee907bd95a1b2452cefd
Diffstat (limited to 'uitest/src/com/vaadin/tests/tb3')
-rw-r--r--uitest/src/com/vaadin/tests/tb3/TB3Runner.java44
-rw-r--r--uitest/src/com/vaadin/tests/tb3/TestNameSuffix.java29
2 files changed, 70 insertions, 3 deletions
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
index eaffa80d09..54bb2d86a5 100644
--- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
+++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
@@ -16,6 +16,7 @@
package com.vaadin.tests.tb3;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
@@ -83,12 +84,21 @@ public class TB3Runner extends BlockJUnit4ClassRunner {
.getAnnotation(RunLocally.class).value()
.getDesiredCapabilities());
}
- for (DesiredCapabilities capabilities : desiredCapabilites) {
+ TestNameSuffix testNameSuffixProperty = findAnnotation(
+ testClassInstance.getClass(), TestNameSuffix.class);
+ for (DesiredCapabilities capabilities : desiredCapabilites) {
// Find any methods marked with @Test.
for (FrameworkMethod m : getTestClass().getAnnotatedMethods(
Test.class)) {
- tests.add(new TB3Method(m.getMethod(), capabilities));
+ TB3Method method = new TB3Method(m.getMethod(),
+ capabilities);
+ if (testNameSuffixProperty != null) {
+ method.setTestNameSuffix("-"
+ + System.getProperty(testNameSuffixProperty
+ .property()));
+ }
+ tests.add(method);
}
}
} catch (Exception e) {
@@ -98,6 +108,27 @@ public class TB3Runner extends BlockJUnit4ClassRunner {
return tests;
}
+ /**
+ * Finds the given annotation in the given class or one of its super
+ * classes. Return the first found annotation
+ *
+ * @param searchClass
+ * @param annotationClass
+ * @return
+ */
+ private <T extends Annotation> T findAnnotation(Class<?> searchClass,
+ Class<T> annotationClass) {
+ if (searchClass == Object.class) {
+ return null;
+ }
+
+ if (searchClass.getAnnotation(annotationClass) != null) {
+ return searchClass.getAnnotation(annotationClass);
+ }
+
+ return findAnnotation(searchClass.getSuperclass(), annotationClass);
+ }
+
/*
* (non-Javadoc)
*
@@ -141,12 +172,17 @@ public class TB3Runner extends BlockJUnit4ClassRunner {
private static class TB3Method extends FrameworkMethod {
private DesiredCapabilities capabilities;
+ private String testNameSuffix = "";
public TB3Method(Method method, DesiredCapabilities capabilities) {
super(method);
this.capabilities = capabilities;
}
+ public void setTestNameSuffix(String testNameSuffix) {
+ this.testNameSuffix = testNameSuffix;
+ }
+
@Override
public Object invokeExplosively(final Object target, Object... params)
throws Throwable {
@@ -156,9 +192,11 @@ public class TB3Runner extends BlockJUnit4ClassRunner {
@Override
public String getName() {
- return String.format("%s[%s]", getMethod().getName(),
+ return String.format("%s[%s]", getMethod().getName()
+ + testNameSuffix,
BrowserUtil.getUniqueIdentifier(capabilities));
}
}
+
}
diff --git a/uitest/src/com/vaadin/tests/tb3/TestNameSuffix.java b/uitest/src/com/vaadin/tests/tb3/TestNameSuffix.java
new file mode 100644
index 0000000000..9f9bb07a13
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/TestNameSuffix.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.tb3;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Defines a system property to be used as part of the test name
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestNameSuffix {
+
+ String property();
+
+}