Fixed: Dependency failures only impact the same instance
diff --git a/CHANGES.txt b/CHANGES.txt
index ea07c1c..01cca5c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,8 +1,11 @@
Current
-Possible backward incompatible changes: don't mutate the value returned
-by XmlTest#getIncludedGroups and XmlTest#getExcludedGroups. Instead, use
-addIncludedGroup/addExcludedGroup.
+Possible backward incompatible changes:
+
+- Don't mutate the value returned by XmlTest#getIncludedGroups and XmlTest#getExcludedGroups.
+Instead, use addIncludedGroup/addExcludedGroup.
+- Failing methods that have dependees will only cause skips in the same instance. Different
+test instances will not be affected
Added: @Factory(dataProvider / dataProviderClass) on constructors
Added: assertNotEquals() to Assert
@@ -11,6 +14,7 @@
Added: <suite preserve-order="true"> will cause this attribute to be propagated to all <test> tags
Added: <groups> can now be specified under a <suite>
Added: Tycho compatibility (Aleksander Pohl)
+Fixed: Dependency failures only impact the same instance
Fixed: Static classes could cause a StackOverFlowError
Fixed: IConfigurationListener was not extending ITestNGListener
Fixed: IConfigurationListener#onConfigurationFailure was never called
diff --git a/src/main/java/org/testng/internal/Invoker.java b/src/main/java/org/testng/internal/Invoker.java
index 5baa732..82981f3 100644
--- a/src/main/java/org/testng/internal/Invoker.java
+++ b/src/main/java/org/testng/internal/Invoker.java
@@ -1602,7 +1602,7 @@
m_testContext.getAllTestMethods(),
element);
- result = result && haveBeenRunSuccessfully(methods);
+ result = result && haveBeenRunSuccessfully(testMethod, methods);
}
} // depends on groups
@@ -1612,31 +1612,40 @@
ITestNGMethod[] methods =
MethodHelper.findDependedUponMethods(testMethod, allTestMethods);
- result = result && haveBeenRunSuccessfully(methods);
+ result = result && haveBeenRunSuccessfully(testMethod, methods);
}
return result;
}
/**
+ * @return the test results that apply to one of the instances of the testMethod.
+ */
+ private Set<ITestResult> keepSameInstances(ITestNGMethod method, Set<ITestResult> results) {
+ Set<ITestResult> result = Sets.newHashSet();
+ for (ITestResult r : results) {
+ for (Object o : method.getInstances()) {
+ if (r.getInstance() == o) result.add(r);
+ }
+ }
+ return result;
+ }
+
+ /**
* @return true if all the methods have been run successfully
*/
- private boolean haveBeenRunSuccessfully(ITestNGMethod[] methods) {
+ private boolean haveBeenRunSuccessfully(ITestNGMethod testMethod, ITestNGMethod[] methods) {
// Make sure the method has been run successfully
for (ITestNGMethod method : methods) {
- Set<ITestResult> results= m_notifier.getPassedTests(method);
- Set<ITestResult> failedresults= m_notifier.getFailedTests(method);
+ Set<ITestResult> results = keepSameInstances(testMethod, m_notifier.getPassedTests(method));
+ Set<ITestResult> failedresults = keepSameInstances(testMethod,
+ m_notifier.getFailedTests(method));
- // If failed results were returned, then these tests didn't pass
+ // If failed results were returned on the same instance, then these tests didn't pass
if (failedresults != null && failedresults.size() > 0) {
return false;
}
- // If no results were returned, then these tests didn't pass
- if (results == null || results.size() == 0) {
- return false;
- }
-
for (ITestResult result : results) {
if(!result.isSuccess()) {
return false;
@@ -1647,6 +1656,17 @@
return true;
}
+ private boolean containsInstance(Set<ITestResult> failedresults, Object[] instances) {
+ for (ITestResult tr : failedresults) {
+ for (Object o : instances) {
+ if (o == tr.getInstance()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
/**
* An exception was thrown by the test, determine if this method
* should be marked as a failure or as failure_but_within_successPercentage
diff --git a/src/test/java/test/dependent/ClassDependsOnGroups.java b/src/test/java/test/dependent/ClassDependsOnGroups.java
index d8dea0e..44ff73f 100644
--- a/src/test/java/test/dependent/ClassDependsOnGroups.java
+++ b/src/test/java/test/dependent/ClassDependsOnGroups.java
@@ -8,15 +8,15 @@
public class ClassDependsOnGroups extends BaseTest {
@Test
public void verifyDependsOnGroups() {
- addClass("test.dependent.DifferentClassDependsOnGroupsTest1");
- addClass("test.dependent.DifferentClassDependsOnGroupsTest2");
+ addClass(test.dependent.DifferentClassDependsOnGroupsTest1.class.getName());
+ addClass(test.dependent.DifferentClassDependsOnGroupsTest2.class.getName());
run();
String[] failed = {
"test0"
};
String[] skipped = {
- "test1", "test2"
+ "test2"
};
verifyTests("Failed", failed, getFailedTests());
verifyTests("Skipped", skipped, getSkippedTests());
diff --git a/src/test/java/test/dependent/MultiGroupTest.java b/src/test/java/test/dependent/MultiGroupTest.java
index f45702a..06ef55d 100644
--- a/src/test/java/test/dependent/MultiGroupTest.java
+++ b/src/test/java/test/dependent/MultiGroupTest.java
@@ -7,18 +7,17 @@
public class MultiGroupTest extends BaseTest {
@Test
public void verifyDependsOnMultiGroups() {
- addClass("test.dependent.MultiGroup1SampleTest");
- addClass("test.dependent.MultiGroup2SampleTest");
+ addClass(MultiGroup1SampleTest.class.getName());
+ addClass(MultiGroup2SampleTest.class.getName());
run();
String[] passed = {
- "testA"
+ "testA", "test2"
};
String[] failed = {
"test1"
};
String[] skipped = {
- "test2"
};
verifyTests("Passed", passed, getPassedTests());
verifyTests("Failed", failed, getFailedTests());