Fixed tests not running on JDK6
diff --git a/build.properties b/build.properties
index cf05fac..c99953b 100644
--- a/build.properties
+++ b/build.properties
@@ -22,7 +22,7 @@
# Names of distributions
#
testng.basename=testng
-testng.version=5.4
+testng.version=5.5beta
jdk14.testng.jar=${testng.basename}-${testng.version}-jdk14.jar
jdk15.testng.jar=${testng.basename}-${testng.version}-jdk15.jar
other.jars.dir=other-jars
diff --git a/doc/download.html b/doc/download.html
index 911ac6e..73bb4fa 100644
--- a/doc/download.html
+++ b/doc/download.html
@@ -65,7 +65,7 @@
<li><a href="http://testng.org/testng-4.7.zip">4.7</a></li>
<li><a href="http://testng.org/testng-5.1.zip">5.1</a></li>
<li><a href="http://testng.org/testng-5.2.zip">5.2</a></li>
- <li><a href="http://testng.org/testng-5.3.zip">5.2</a></li>
+ <li><a href="http://testng.org/testng-5.3.zip">5.3</a></li>
</ul>
<p>TestNG is also <a href="http://code.google.com/hosting/search?q=testng&btn=Search+Projects">hosted on Google Code</a>,
where you can download the source through the Subversion repository or subscribe to the various mailing-lists.</p>
diff --git a/src/main/org/testng/internal/MethodHelper.java b/src/main/org/testng/internal/MethodHelper.java
index 3f012ce..adbeb0f 100644
--- a/src/main/org/testng/internal/MethodHelper.java
+++ b/src/main/org/testng/internal/MethodHelper.java
@@ -144,25 +144,27 @@
List<ITestNGMethod> vResult = new ArrayList<ITestNGMethod>();
String currentRegexp = null;
for (String fullyQualifiedRegexp : regexps) {
- String regexp = escapeRegexp(fullyQualifiedRegexp);
boolean foundAtLeastAMethod = false;
- if (regexp != null) {
+
+ if(null != fullyQualifiedRegexp) {
+ String regexp = escapeRegexp(fullyQualifiedRegexp);
currentRegexp = regexp;
boolean usePackage = regexp.indexOf(".") != -1;
+
for (ITestNGMethod method : methods) {
Method thisMethod = method.getMethod();
String thisMethodName = thisMethod.getName();
String methodName = usePackage ?
calculateMethodCanonicalName(thisMethod)
: thisMethodName;
-// ppp("COMPARING\n" + regexp + "\n" + methodName);
+// ppp("COMPARING\n" + regexp + "\n" + methodName);
if (Pattern.matches(regexp, methodName)) {
vResult.add(method);
foundAtLeastAMethod = true;
}
}
}
-
+
if (!foundAtLeastAMethod) {
throw new TestNGException(mainMethod
+ "() is depending on nonexistent method " + currentRegexp);
diff --git a/src/main/org/testng/internal/annotations/JDK14AnnotationFinder.java b/src/main/org/testng/internal/annotations/JDK14AnnotationFinder.java
index 0fdd91b..9975266 100644
--- a/src/main/org/testng/internal/annotations/JDK14AnnotationFinder.java
+++ b/src/main/org/testng/internal/annotations/JDK14AnnotationFinder.java
@@ -60,8 +60,9 @@
for (int i = 0; i < m_dirPaths.length; i++) {
File dir = new File(m_dirPaths[i]);
- if(!dir.exists() || dir.isDirectory()) {
+ if(!dir.exists() || !dir.isDirectory()) {
Utils.log(getClass().getName(), 1, "[WARNING] Invalid source directory " + m_dirPaths[i] + " ignored");
+ continue;
}
DirectoryScanner scanner = new DirectoryScanner(dir);
scanner.addFilter(new SuffixFilter(".java"));
diff --git a/test/src/test/GraphTest.java b/test/src/test/GraphTest.java
index f9b2850..77df0b6 100644
--- a/test/src/test/GraphTest.java
+++ b/test/src/test/GraphTest.java
@@ -2,7 +2,8 @@
import java.util.List;
-import org.testng.annotations.*;
+import org.testng.annotations.ExpectedExceptions;
+import org.testng.annotations.Test;
import org.testng.internal.Graph;
@@ -94,17 +95,18 @@
{
List<String> predecessors = g.findPredecessors("3");
+
assert predecessors.size() == 4;
assert predecessors.get(0).equals("1");
- assert predecessors.get(1).equals("2.1") ||
- predecessors.get(2).equals("2.2") ||
- predecessors.get(2).equals("2");
- assert predecessors.get(2).equals("2.1") ||
- predecessors.get(2).equals("2.2") ||
- predecessors.get(2).equals("2");
- assert predecessors.get(3).equals("2.1") ||
- predecessors.get(2).equals("2.2") ||
- predecessors.get(2).equals("2");
+ assert predecessors.get(1).equals("2.1")
+ || predecessors.get(1).equals("2.2")
+ || predecessors.get(1).equals("2");
+ assert predecessors.get(2).equals("2.1")
+ || predecessors.get(2).equals("2.2")
+ || predecessors.get(2).equals("2");
+ assert predecessors.get(3).equals("2.1")
+ || predecessors.get(3).equals("2.2")
+ || predecessors.get(3).equals("2");
}
}
}
diff --git a/test/src/test/interleavedorder/InterleavedInvocationTest.java b/test/src/test/interleavedorder/InterleavedInvocationTest.java
index 9175d62..4162c29 100644
--- a/test/src/test/interleavedorder/InterleavedInvocationTest.java
+++ b/test/src/test/interleavedorder/InterleavedInvocationTest.java
@@ -33,18 +33,18 @@
final String log= LOG.toString();
final String clsName= TestChild1.class.getName();
-
- List<String> expected = new ArrayList<String>();
- expected.add("beforeTestChild1Class");
- expected.add("test1");
- expected.add("test2");
- expected.add("afterTestChild1Class");
-
- expected.add("beforeTestChild2Class");
- expected.add("test1");
- expected.add("test2");
- expected.add("afterTestChild2Class");
- Assert.assertEquals(LOG, expected);
+
+
+ Assert.assertEquals(LOG.size(), 8, "invocations");
+ // @Configuration ordering
+ Assert.assertEquals(LOG.get(0), "beforeTestChild1Class");
+ Assert.assertTrue(("test1".equals(LOG.get(1)) && "test2".equals(LOG.get(2)))
+ || ("test2".equals(LOG.get(1)) && "test1".equals(LOG.get(2))), "test methods were not invoked correctly");
+ Assert.assertEquals(LOG.get(3), "afterTestChild1Class");
+ Assert.assertEquals(LOG.get(4), "beforeTestChild2Class");
+ Assert.assertTrue(("test1".equals(LOG.get(5)) && "test2".equals(LOG.get(6)))
+ || ("test2".equals(LOG.get(5)) && "test1".equals(LOG.get(6))), "test methods were not invoked correctly");
+ Assert.assertEquals(LOG.get(7), "afterTestChild2Class");
}
public static void ppp(String s) {
diff --git a/test/src/test/mannotation/MAnnotationSampleTest.java b/test/src/test/mannotation/MAnnotationSampleTest.java
index a3bf46d..04d0c53 100644
--- a/test/src/test/mannotation/MAnnotationSampleTest.java
+++ b/test/src/test/mannotation/MAnnotationSampleTest.java
@@ -24,11 +24,6 @@
@Configuration(beforeTestClass = true, enabled = true)
public void init() {
m_finder = new JDK15AnnotationFinder(new DefaultAnnotationTransformer());
-// m_finder.addSourceDirs(new String[] {
-// "./test-14/src",
-// "src"
-// });
-
}
public void verifyTestClassLevel() {
@@ -37,18 +32,17 @@
//
ITest test1 = (ITest) m_finder.findAnnotation(MTest1.class, ITest.class);
Assert.assertTrue(test1.getEnabled());
- String[] groups = test1.getGroups();
- Assert.assertEquals(new String[] { "group1", "group2" }, groups);
+ Assert.assertEquals(test1.getGroups(), new String[] { "group1", "group2" });
Assert.assertTrue(test1.getAlwaysRun());
- Assert.assertEquals(new String[] { "param1", "param2" }, test1.getParameters());
- Assert.assertEquals(new String[] { "dg1", "dg2" }, test1.getDependsOnGroups());
- Assert.assertEquals(new String[] { "dm1", "dm2" }, test1.getDependsOnMethods());
- Assert.assertEquals(42, test1.getTimeOut());
- Assert.assertEquals(43, test1.getInvocationCount());
- Assert.assertEquals(44, test1.getSuccessPercentage());
- Assert.assertEquals(3, test1.getThreadPoolSize());
- Assert.assertEquals("dp", test1.getDataProvider());
- Assert.assertEquals("Class level description", test1.getDescription());
+ Assert.assertEquals(test1.getParameters(), new String[] { "param1", "param2" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2" }, "depends on groups");
+ Assert.assertEqualsNoOrder( test1.getDependsOnMethods(), new String[] { "dm1", "dm2" });
+ Assert.assertEquals(test1.getTimeOut(), 42);
+ Assert.assertEquals(test1.getInvocationCount(), 43);
+ Assert.assertEquals(test1.getSuccessPercentage(), 44);
+ Assert.assertEquals(test1.getThreadPoolSize(), 3);
+ Assert.assertEquals(test1.getDataProvider(), "dp");
+ Assert.assertEquals(test1.getDescription(), "Class level description");
//
// Tests on MTest1SampleTest (test defaults)
@@ -57,14 +51,13 @@
// test default for enabled
Assert.assertTrue(test2.getEnabled());
Assert.assertFalse(test2.getAlwaysRun());
- Assert.assertEquals(0, test2.getTimeOut());
- Assert.assertEquals(1, test2.getInvocationCount());
- Assert.assertEquals(100, test2.getSuccessPercentage());
- Assert.assertEquals("", test2.getDataProvider());
+ Assert.assertEquals(test2.getTimeOut(), 0);
+ Assert.assertEquals(test2.getInvocationCount(), 1);
+ Assert.assertEquals(test2.getSuccessPercentage(), 100);
+ Assert.assertEquals(test2.getDataProvider(), "");
}
- public void verifyTestMethodLevel()
- throws SecurityException, NoSuchMethodException
+ public void verifyTestMethodLevel() throws SecurityException, NoSuchMethodException
{
//
// Tests on MTest1SampleTest
@@ -72,24 +65,22 @@
Method method = MTest1.class.getMethod("f", new Class[0]);
ITest test1 = (ITest) m_finder.findAnnotation(method, ITest.class);
Assert.assertTrue(test1.getEnabled());
- String[] groups = test1.getGroups();
- Assert.assertEquals(new String[] { "group1", "group3", "group4", "group2" }, groups);
+ Assert.assertEqualsNoOrder(test1.getGroups(), new String[] { "group1", "group3", "group4", "group2" });
Assert.assertTrue(test1.getAlwaysRun());
- Assert.assertEquals(new String[] { "param3", "param4" }, test1.getParameters());
- Assert.assertEqualsNoOrder(new String[] { "dg1", "dg2", "dg3", "dg4" }, test1.getDependsOnGroups());
- Assert.assertEqualsNoOrder(new String[] { "dm1", "dm2", "dm3", "dm4" }, test1.getDependsOnMethods());
- Assert.assertEquals(142, test1.getTimeOut());
- Assert.assertEquals(143, test1.getInvocationCount());
- Assert.assertEquals(61, test1.getSuccessPercentage());
- Assert.assertEquals("dp2", test1.getDataProvider());
- Assert.assertEquals("Method description", test1.getDescription());
+ Assert.assertEquals(test1.getParameters(), new String[] { "param3", "param4" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2", "dg3", "dg4" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnMethods(), new String[] { "dm1", "dm2", "dm3", "dm4" });
+ Assert.assertEquals(test1.getTimeOut(), 142);
+ Assert.assertEquals(test1.getInvocationCount(), 143);
+ Assert.assertEquals(test1.getSuccessPercentage(), 61);
+ Assert.assertEquals(test1.getDataProvider(), "dp2");
+ Assert.assertEquals(test1.getDescription(), "Method description");
Class[] exceptions = test1.getExpectedExceptions();
Assert.assertEquals(exceptions.length, 1);
Assert.assertEquals(exceptions[0], NullPointerException.class);
}
- public void verifyTestConstructorLevel()
- throws SecurityException, NoSuchMethodException
+ public void verifyTestConstructorLevel() throws SecurityException, NoSuchMethodException
{
//
// Tests on MTest1SampleTest
@@ -98,24 +89,22 @@
ITest test1 = (ITest) m_finder.findAnnotation(constructor, ITest.class);
Assert.assertNotNull(test1);
Assert.assertTrue(test1.getEnabled());
- String[] groups = test1.getGroups();
- Assert.assertEquals(new String[] { "group5", "group1", "group6", "group2" }, groups);
+ Assert.assertEqualsNoOrder(test1.getGroups(), new String[] { "group5", "group1", "group6", "group2" });
Assert.assertTrue(test1.getAlwaysRun());
- Assert.assertEquals(new String[] { "param5", "param6" }, test1.getParameters());
- Assert.assertEqualsNoOrder(new String[] { "dg1", "dg2", "dg5", "dg6" }, test1.getDependsOnGroups());
- Assert.assertEqualsNoOrder(new String[] { "dm1", "dm2", "dm5", "dm6" }, test1.getDependsOnMethods());
- Assert.assertEquals(242, test1.getTimeOut());
- Assert.assertEquals(243, test1.getInvocationCount());
- Assert.assertEquals(62, test1.getSuccessPercentage());
- Assert.assertEquals("dp3", test1.getDataProvider());
- Assert.assertEquals("Constructor description", test1.getDescription());
+ Assert.assertEquals(test1.getParameters(), new String[] { "param5", "param6" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2", "dg5", "dg6" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnMethods(), new String[] { "dm1", "dm2", "dm5", "dm6" });
+ Assert.assertEquals(test1.getTimeOut(), 242);
+ Assert.assertEquals(test1.getInvocationCount(), 243);
+ Assert.assertEquals(test1.getSuccessPercentage(), 62);
+ Assert.assertEquals(test1.getDataProvider(), "dp3");
+ Assert.assertEquals(test1.getDescription(), "Constructor description");
Class[] exceptions = test1.getExpectedExceptions();
Assert.assertEquals(exceptions.length, 1);
Assert.assertEquals(exceptions[0], NumberFormatException.class);
}
- public void verifyConfigurationBefore()
- throws SecurityException, NoSuchMethodException
+ public void verifyConfigurationBefore() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("before", new Class[0]);
IConfiguration configuration =
@@ -132,8 +121,7 @@
Assert.assertEquals(0, configuration.getAfterGroups().length);
String[] bg = configuration.getBeforeGroups();
Assert.assertEquals(bg.length, 2);
- Assert.assertTrue((bg[0].equals("b1") && bg[1].equals("b2"))
- || (bg[1].equals("b1") && bg[0].equals("b2")));
+ Assert.assertEqualsNoOrder(bg, new String[] {"b1", "b2"});
// Default values
Assert.assertTrue(configuration.getEnabled());
@@ -141,8 +129,7 @@
Assert.assertFalse(configuration.getAlwaysRun());
}
- public void verifyConfigurationAfter()
- throws SecurityException, NoSuchMethodException
+ public void verifyConfigurationAfter() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("after", new Class[0]);
IConfiguration configuration =
@@ -159,8 +146,7 @@
Assert.assertEquals(0, configuration.getBeforeGroups().length);
String[] ag = configuration.getAfterGroups();
Assert.assertEquals(ag.length, 2);
- Assert.assertTrue((ag[0].equals("a1") && ag[1].equals("a2"))
- || (ag[1].equals("a1") && ag[0].equals("a2")));
+ Assert.assertEqualsNoOrder(ag, new String[] {"a1", "a2"});
// Default values
Assert.assertTrue(configuration.getEnabled());
@@ -168,8 +154,7 @@
Assert.assertFalse(configuration.getAlwaysRun());
}
- public void verifyConfigurationOthers()
- throws SecurityException, NoSuchMethodException
+ public void verifyConfigurationOthers() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("otherConfigurations", new Class[0]);
IConfiguration configuration =
@@ -185,50 +170,45 @@
Assert.assertFalse(configuration.getAfterTestClass());
Assert.assertFalse(configuration.getEnabled());
- Assert.assertEquals(new String[] { "oparam1", "oparam2" }, configuration.getParameters());
- Assert.assertEquals(new String[] { "group1", "ogroup1", "ogroup2", "group2" }, configuration.getGroups());
- Assert.assertEquals(new String[] { "odg1", "odg2" }, configuration.getDependsOnGroups());
- Assert.assertEquals(new String[] { "odm1", "odm2" }, configuration.getDependsOnMethods());
+ Assert.assertEquals(configuration.getParameters(), new String[] { "oparam1", "oparam2" });
+ Assert.assertEqualsNoOrder(configuration.getGroups(), new String[] { "group1", "ogroup1", "ogroup2", "group2" }, "groups");
+ Assert.assertEqualsNoOrder(configuration.getDependsOnGroups(), new String[] { "odg1", "odg2" }, "depends on groups");
+ Assert.assertEqualsNoOrder(configuration.getDependsOnMethods(), new String[] { "odm1", "odm2" }, "depends on methods");
Assert.assertFalse(configuration.getInheritGroups());
Assert.assertTrue(configuration.getAlwaysRun());
Assert.assertEquals(configuration.getDescription(), "beforeSuite description");
}
- public void verifyDataProvider()
- throws SecurityException, NoSuchMethodException
+ public void verifyDataProvider() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("otherConfigurations", new Class[0]);
IDataProvider dataProvider =
(IDataProvider) m_finder.findAnnotation(method, IDataProvider.class);
Assert.assertNotNull(dataProvider);
- Assert.assertEquals("dp4", dataProvider.getName());
+ Assert.assertEquals(dataProvider.getName(), "dp4");
}
- public void verifyExpectedExceptions()
- throws SecurityException, NoSuchMethodException
+ public void verifyExpectedExceptions() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("otherConfigurations", new Class[0]);
IExpectedExceptions exceptions=
(IExpectedExceptions) m_finder.findAnnotation(method, IExpectedExceptions.class);
Assert.assertNotNull(exceptions);
- Assert.assertEquals(new Class[] { MTest1.class, MTest2.class }, exceptions.getValue());
+ Assert.assertEquals(exceptions.getValue(), new Class[] { MTest1.class, MTest2.class });
}
- public void verifyFactory()
- throws SecurityException, NoSuchMethodException
+ public void verifyFactory() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("factory", new Class[0]);
IFactory factory=
(IFactory) m_finder.findAnnotation(method, IFactory.class);
Assert.assertNotNull(factory);
- Assert.assertEquals(new String[] { "pf1", "pf2" }, factory.getParameters());
+ Assert.assertEquals(factory.getParameters(), new String[] { "pf1", "pf2" });
}
- @Test
- public void verifyParameters()
- throws SecurityException, NoSuchMethodException
+ public void verifyParameters() throws SecurityException, NoSuchMethodException
{
m_finder = new JDK15AnnotationFinder(new DefaultAnnotationTransformer());
Method method = MTest1.class.getMethod("parameters", new Class[0]);
@@ -236,11 +216,10 @@
(IParameters) m_finder.findAnnotation(method, IParameters.class);
Assert.assertNotNull(parameters);
- Assert.assertEquals(new String[] { "pp1", "pp2", "pp3" }, parameters.getValue());
+ Assert.assertEquals(parameters.getValue(), new String[] { "pp1", "pp2", "pp3" });
}
- public void verifyNewConfigurationBefore()
- throws SecurityException, NoSuchMethodException
+ public void verifyNewConfigurationBefore() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("newBefore", new Class[0]);
IConfiguration configuration =
@@ -254,8 +233,7 @@
Assert.assertFalse(configuration.getAlwaysRun());
}
- public void verifyNewConfigurationAfter()
- throws SecurityException, NoSuchMethodException
+ public void verifyNewConfigurationAfter() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("newAfter", new Class[0]);
IConfiguration configuration =
diff --git a/test/testng-single2.xml b/test/testng-single2.xml
index fa852ef..7722e09 100644
--- a/test/testng-single2.xml
+++ b/test/testng-single2.xml
@@ -1,31 +1,23 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
-<suite name="Single" verbose="3" parallel="false" >
- <test name="BeforeGroups-AfterGroups-1" >
+<suite name="Single" verbose="3" parallel="false" >
+ <test name="Test order invocation">
<classes>
- <!--<class name="test.configuration.ConfigurationGroups1SampleTest" />
- <class name="test.configuration.ConfigurationGroups2SampleTest" />-->
- <class name="test.configuration.ConfigurationGroups3SampleTest" />
- <!--
- <class name="test.configuration.ConfigurationGroups4SampleTest" />
- <class name="test.configuration.ConfigurationGroups5SampleTest" />
- <class name="test.configuration.ConfigurationGroups6SampleTest" />
- <class name="test.configuration.ConfigurationGroups7SampleTest" />
- -->
+ <class name="test.interleavedorder.InterleavedInvocationTest" />
</classes>
</test>
- <!--
- <test name="BeforeGroups-AfterGroups-2" >
- <groups>
- <run>
- <include name="A" />
- <include name="B" />
- </run>
- </groups>
+ <test name="Regression2">
<classes>
- <class name="test.configuration.ConfigurationGroups8SampleTest" />
+ <class name="test.GraphTest"/>
+ <class name="test.mannotation.MAnnotationSampleTest" />
+ <class name="test.mannotation.MAnnotation2SampleTest" />
</classes>
</test>
- -->
+ <test name="Dependents">
+ <parameter name="foo" value="Cedric" />
+ <classes>
+ <class name="test.dependent.DependentTest" />
+ </classes>
+ </test>
</suite>
diff --git a/test/v4/src/test/GraphTest.java b/test/v4/src/test/GraphTest.java
index f9b2850..55580d4 100644
--- a/test/v4/src/test/GraphTest.java
+++ b/test/v4/src/test/GraphTest.java
@@ -96,15 +96,15 @@
List<String> predecessors = g.findPredecessors("3");
assert predecessors.size() == 4;
assert predecessors.get(0).equals("1");
- assert predecessors.get(1).equals("2.1") ||
- predecessors.get(2).equals("2.2") ||
- predecessors.get(2).equals("2");
- assert predecessors.get(2).equals("2.1") ||
- predecessors.get(2).equals("2.2") ||
- predecessors.get(2).equals("2");
- assert predecessors.get(3).equals("2.1") ||
- predecessors.get(2).equals("2.2") ||
- predecessors.get(2).equals("2");
+ assert predecessors.get(1).equals("2.1")
+ || predecessors.get(1).equals("2.2")
+ || predecessors.get(1).equals("2");
+ assert predecessors.get(2).equals("2.1")
+ || predecessors.get(2).equals("2.2")
+ || predecessors.get(2).equals("2");
+ assert predecessors.get(3).equals("2.1")
+ || predecessors.get(3).equals("2.2")
+ || predecessors.get(3).equals("2");
}
}
}
diff --git a/test/v4/src/test/interleavedorder/InterleavedInvocationTest.java b/test/v4/src/test/interleavedorder/InterleavedInvocationTest.java
index e6835ff..b1e03b1 100644
--- a/test/v4/src/test/interleavedorder/InterleavedInvocationTest.java
+++ b/test/v4/src/test/interleavedorder/InterleavedInvocationTest.java
@@ -35,17 +35,16 @@
final String log= LOG.toString();
final String clsName= TestChild1.class.getName();
- List<String> expected = new ArrayList<String>();
- expected.add("beforeTestChild1Class");
- expected.add("test1");
- expected.add("test2");
- expected.add("afterTestChild1Class");
-
- expected.add("beforeTestChild2Class");
- expected.add("test1");
- expected.add("test2");
- expected.add("afterTestChild2Class");
- Assert.assertEquals(LOG, expected);
+ Assert.assertEquals(LOG.size(), 8, "invocations");
+ // @Configuration ordering
+ Assert.assertEquals(LOG.get(0), "beforeTestChild1Class");
+ Assert.assertTrue(("test1".equals(LOG.get(1)) && "test2".equals(LOG.get(2)))
+ || ("test2".equals(LOG.get(1)) && "test1".equals(LOG.get(2))), "test methods were not invoked correctly");
+ Assert.assertEquals(LOG.get(3), "afterTestChild1Class");
+ Assert.assertEquals(LOG.get(4), "beforeTestChild2Class");
+ Assert.assertTrue(("test1".equals(LOG.get(5)) && "test2".equals(LOG.get(6)))
+ || ("test2".equals(LOG.get(5)) && "test1".equals(LOG.get(6))), "test methods were not invoked correctly");
+ Assert.assertEquals(LOG.get(7), "afterTestChild2Class");
}
private void ppp(String s) {
diff --git a/test/v4/src/test/mannotation/MAnnotationSampleTest.java b/test/v4/src/test/mannotation/MAnnotationSampleTest.java
index 1291b77..29513f3 100644
--- a/test/v4/src/test/mannotation/MAnnotationSampleTest.java
+++ b/test/v4/src/test/mannotation/MAnnotationSampleTest.java
@@ -30,19 +30,18 @@
//
ITest test1 = (ITest) m_finder.findAnnotation(MTest1.class, ITest.class);
Assert.assertTrue(test1.getEnabled());
- String[] groups = test1.getGroups();
- Assert.assertEquals(new String[] { "group1", "group2" }, groups);
+ Assert.assertEquals(test1.getGroups(), new String[] { "group1", "group2" });
Assert.assertTrue(test1.getAlwaysRun());
- Assert.assertEquals(new String[] { "param1", "param2" }, test1.getParameters());
- Assert.assertEquals(new String[] { "dg1", "dg2" }, test1.getDependsOnGroups());
- Assert.assertEquals(new String[] { "dm1", "dm2" }, test1.getDependsOnMethods());
- Assert.assertEquals(42, test1.getTimeOut());
- Assert.assertEquals(43, test1.getInvocationCount());
- Assert.assertEquals(44, test1.getSuccessPercentage());
- Assert.assertEquals(3, test1.getThreadPoolSize());
- Assert.assertEquals("dp", test1.getDataProvider());
- Assert.assertEquals("Class level description", test1.getDescription());
-
+ Assert.assertEquals(test1.getParameters(), new String[] { "param1", "param2" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2" }, "depends on groups");
+ Assert.assertEqualsNoOrder( test1.getDependsOnMethods(), new String[] { "dm1", "dm2" });
+ Assert.assertEquals(test1.getTimeOut(), 42);
+ Assert.assertEquals(test1.getInvocationCount(), 43);
+ Assert.assertEquals(test1.getSuccessPercentage(), 44);
+ Assert.assertEquals(test1.getThreadPoolSize(), 3);
+ Assert.assertEquals(test1.getDataProvider(), "dp");
+ Assert.assertEquals(test1.getDescription(), "Class level description");
+
//
// Tests on MTest1SampleTest (test defaults)
//
@@ -50,14 +49,13 @@
// test default for enabled
Assert.assertTrue(test2.getEnabled());
Assert.assertFalse(test2.getAlwaysRun());
- Assert.assertEquals(0, test2.getTimeOut());
- Assert.assertEquals(1, test2.getInvocationCount());
- Assert.assertEquals(100, test2.getSuccessPercentage());
- Assert.assertEquals("", test2.getDataProvider());
+ Assert.assertEquals(test2.getTimeOut(), 0);
+ Assert.assertEquals(test2.getInvocationCount(), 1);
+ Assert.assertEquals(test2.getSuccessPercentage(), 100);
+ Assert.assertEquals(test2.getDataProvider(), "");
}
- public void verifyTestMethodLevel()
- throws SecurityException, NoSuchMethodException
+ public void verifyTestMethodLevel() throws SecurityException, NoSuchMethodException
{
//
// Tests on MTest1SampleTest
@@ -65,21 +63,19 @@
Method method = MTest1.class.getMethod("f", new Class[0]);
ITest test1 = (ITest) m_finder.findAnnotation(method, ITest.class);
Assert.assertTrue(test1.getEnabled());
- String[] groups = test1.getGroups();
- Assert.assertEquals(new String[] { "group1", "group3", "group4", "group2" }, groups);
+ Assert.assertEqualsNoOrder(test1.getGroups(), new String[] { "group1", "group3", "group4", "group2" });
Assert.assertTrue(test1.getAlwaysRun());
- Assert.assertEquals(new String[] { "param3", "param4" }, test1.getParameters());
- Assert.assertEqualsNoOrder(new String[] { "dg1", "dg2", "dg3", "dg4" }, test1.getDependsOnGroups());
- Assert.assertEqualsNoOrder(new String[] { "dm1", "dm2", "dm3", "dm4" }, test1.getDependsOnMethods());
- Assert.assertEquals(142, test1.getTimeOut());
- Assert.assertEquals(143, test1.getInvocationCount());
- Assert.assertEquals(61, test1.getSuccessPercentage());
- Assert.assertEquals("dp2", test1.getDataProvider());
- Assert.assertEquals("Method description", test1.getDescription());
+ Assert.assertEquals(test1.getParameters(), new String[] { "param3", "param4" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2", "dg3", "dg4" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnMethods(), new String[] { "dm1", "dm2", "dm3", "dm4" });
+ Assert.assertEquals(test1.getTimeOut(), 142);
+ Assert.assertEquals(test1.getInvocationCount(), 143);
+ Assert.assertEquals(test1.getSuccessPercentage(), 61);
+ Assert.assertEquals(test1.getDataProvider(), "dp2");
+ Assert.assertEquals(test1.getDescription(), "Method description");
}
- public void verifyTestConstructorLevel()
- throws SecurityException, NoSuchMethodException
+ public void verifyTestConstructorLevel() throws SecurityException, NoSuchMethodException
{
//
// Tests on MTest1SampleTest
@@ -88,21 +84,19 @@
ITest test1 = (ITest) m_finder.findAnnotation(constructor, ITest.class);
Assert.assertNotNull(test1);
Assert.assertTrue(test1.getEnabled());
- String[] groups = test1.getGroups();
- Assert.assertEquals(new String[] { "group5", "group1", "group6", "group2" }, groups);
+ Assert.assertEqualsNoOrder(test1.getGroups(), new String[] { "group5", "group1", "group6", "group2" });
Assert.assertTrue(test1.getAlwaysRun());
- Assert.assertEquals(new String[] { "param5", "param6" }, test1.getParameters());
- Assert.assertEqualsNoOrder(new String[] { "dg1", "dg2", "dg5", "dg6" }, test1.getDependsOnGroups());
- Assert.assertEqualsNoOrder(new String[] { "dm1", "dm2", "dm5", "dm6" }, test1.getDependsOnMethods());
- Assert.assertEquals(242, test1.getTimeOut());
- Assert.assertEquals(243, test1.getInvocationCount());
- Assert.assertEquals(62, test1.getSuccessPercentage());
- Assert.assertEquals("dp3", test1.getDataProvider());
- Assert.assertEquals("Constructor description", test1.getDescription());
+ Assert.assertEquals(test1.getParameters(), new String[] { "param5", "param6" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2", "dg5", "dg6" });
+ Assert.assertEqualsNoOrder(test1.getDependsOnMethods(), new String[] { "dm1", "dm2", "dm5", "dm6" });
+ Assert.assertEquals(test1.getTimeOut(), 242);
+ Assert.assertEquals(test1.getInvocationCount(), 243);
+ Assert.assertEquals(test1.getSuccessPercentage(), 62);
+ Assert.assertEquals(test1.getDataProvider(), "dp3");
+ Assert.assertEquals(test1.getDescription(), "Constructor description");
}
- public void verifyConfigurationBefore()
- throws SecurityException, NoSuchMethodException
+ public void verifyConfigurationBefore() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("before", new Class[0]);
IConfiguration configuration =
@@ -128,8 +122,7 @@
Assert.assertFalse(configuration.getAlwaysRun());
}
- public void verifyConfigurationAfter()
- throws SecurityException, NoSuchMethodException
+ public void verifyConfigurationAfter() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("after", new Class[0]);
IConfiguration configuration =
@@ -155,8 +148,7 @@
Assert.assertFalse(configuration.getAlwaysRun());
}
- public void verifyConfigurationOthers()
- throws SecurityException, NoSuchMethodException
+ public void verifyConfigurationOthers() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("otherConfigurations", new Class[0]);
IConfiguration configuration =
@@ -170,12 +162,12 @@
Assert.assertFalse(configuration.getAfterTestMethod());
Assert.assertFalse(configuration.getAfterTest());
Assert.assertFalse(configuration.getAfterTestClass());
-
+
Assert.assertFalse(configuration.getEnabled());
- Assert.assertEquals(new String[] { "oparam1", "oparam2" }, configuration.getParameters());
- Assert.assertEquals(new String[] { "group1", "ogroup1", "ogroup2", "group2" }, configuration.getGroups());
- Assert.assertEquals(new String[] { "odg1", "odg2" }, configuration.getDependsOnGroups());
- Assert.assertEquals(new String[] { "odm1", "odm2" }, configuration.getDependsOnMethods());
+ Assert.assertEquals(configuration.getParameters(), new String[] { "oparam1", "oparam2" });
+ Assert.assertEqualsNoOrder(configuration.getGroups(), new String[] { "group1", "ogroup1", "ogroup2", "group2" }, "groups");
+ Assert.assertEqualsNoOrder(configuration.getDependsOnGroups(), new String[] { "odg1", "odg2" }, "depends on groups");
+ Assert.assertEqualsNoOrder(configuration.getDependsOnMethods(), new String[] { "odm1", "odm2" }, "depends on methods");
Assert.assertFalse(configuration.getInheritGroups());
Assert.assertTrue(configuration.getAlwaysRun());
Assert.assertEquals(configuration.getDescription(), "beforeSuite description");