Author: lfryc(a)redhat.com
Date: 2010-09-02 07:50:39 -0400 (Thu, 02 Sep 2010)
New Revision: 19091
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java
Log:
Optimization for skipping all subsequent test method invocations, if the method failed for
plan template.
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-09-02
10:26:45 UTC (rev 19090)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-09-02
11:50:39 UTC (rev 19091)
@@ -33,9 +33,11 @@
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
+import org.richfaces.tests.metamer.Template;
import org.richfaces.tests.metamer.TemplatesList;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Templates;
+import org.testng.ITestResult;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -79,8 +81,20 @@
selenium.open(buildUrl(getTestUrl() + "?templates=" +
template.toString()));
selenium.waitForPageToLoad(TIMEOUT);
}
-
+
/**
+ * Optimization for skipping all subsequent test method invocations, if the method
failed for plan template.
+ */
+ @AfterMethod(alwaysRun = true)
+ public void skipAllAfterPlainTemplateFailure(ITestResult result) {
+ if (template.size() == 1 && template.get(0) == Template.PLAIN) {
+ if (result.getStatus() == ITestResult.FAILURE) {
+ result.getMethod().setSkipFailedInvocations(true);
+ }
+ }
+ }
+
+ /**
* Invalidates session by clicking on a button on tested page.
*/
@AfterMethod(alwaysRun = true)
@@ -134,13 +148,13 @@
selenium.waitForPageToLoad(TIMEOUT);
selenium.fireEvent(element, event);
-
+
waitGui.until(new JavaScriptCondition() {
public JavaScript getJavaScriptCondition() {
return new JavaScript("selenium.isAlertPresent()");
}
});
-
+
assertEquals(selenium.getAlert(), event.getEventName(), event.getEventName()
+ " attribute did not change correctly");
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java 2010-09-02
10:26:45 UTC (rev 19090)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java 2010-09-02
11:50:39 UTC (rev 19091)
@@ -98,10 +98,32 @@
}
}
+ public void onTestStart(ITestResult result) {
+ if (!methodConfigured) {
+ configureMethod(result);
+ methodConfigured = true;
+ }
+ }
+
+ public void onTestSuccess(ITestResult result) {
+ methodConfigured = false;
+ }
+
+ public void onTestFailure(ITestResult result) {
+ methodConfigured = false;
+ }
+
public void onTestSkipped(ITestResult result) {
- configureMethod(result);
+ if (!methodConfigured) {
+ configureMethod(result);
+ }
+ methodConfigured = false;
}
+ public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
+ methodConfigured = false;
+ }
+
private boolean isAfterConfiguration(ITestNGMethod m) {
return m.isAfterClassConfiguration() || m.isAfterGroupsConfiguration() ||
m.isAfterMethodConfiguration()
|| m.isAfterSuiteConfiguration() || m.isAfterTestConfiguration();
@@ -139,17 +161,10 @@
}
}
- public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
- if (method.isTestMethod()) {
- methodConfigured = false;
- }
- }
-
public void transform(ITestAnnotation annotation, Class testClass, Constructor
testConstructor, Method testMethod) {
super.transform(annotation, testClass, testConstructor, testMethod);
int invocationCount = createConfiguration(testMethod.getDeclaringClass(),
testMethod);
annotation.setInvocationCount(invocationCount);
- annotation.setSkipFailedInvocations(true);
}
public int createConfiguration(Class<?> realClass, Method realMethod) {
@@ -480,21 +495,12 @@
}
}
- public void onTestStart(ITestResult result) {
- }
-
- public void onTestSuccess(ITestResult result) {
- }
-
- public void onTestFailure(ITestResult result) {
- }
-
- public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
- }
-
public void onStart(ITestContext context) {
}
public void onFinish(ITestContext context) {
}
+
+ public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
+ }
}
Show replies by date