Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: -testjar supports jar file with no testng.xml file
- Loading branch information
cbeust
committed
Apr 6, 2008
1 parent
ee84a0e
commit 01f7479
Showing
12 changed files
with
133 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package test.jar; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
public class A { | ||
|
||
@Test | ||
public void f() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package test.jar; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
public class B { | ||
|
||
@Test | ||
public void g() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package test.jar; | ||
|
||
import org.testng.Assert; | ||
import org.testng.TestListenerAdapter; | ||
import org.testng.TestNG; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
|
||
public class JarTest { | ||
private TestListenerAdapter init(String jarFile) { | ||
TestNG tng = new TestNG(); | ||
File currentDir = new File("."); | ||
String path = currentDir.getAbsolutePath(); | ||
char s = File.separatorChar; | ||
path = path + s + "test" + s + "src" + s + "test" + s + "jar" + s; | ||
String finalPath = path + jarFile; | ||
tng.setTestJar(finalPath); | ||
TestListenerAdapter result = new TestListenerAdapter(); | ||
tng.addListener(result); | ||
tng.run(); | ||
|
||
return result; | ||
} | ||
|
||
@Test | ||
public void jarWithTestngXml() { | ||
TestListenerAdapter tla = init("withtestngxml.jar"); | ||
Assert.assertEquals(tla.getPassedTests().size(), 1); | ||
Assert.assertEquals(tla.getPassedTests().get(0).getName(), "f"); | ||
} | ||
|
||
@Test | ||
public void jarWithoutTestngXml() { | ||
TestListenerAdapter tla = init("withouttestngxml.jar"); | ||
Assert.assertEquals(tla.getPassedTests().size(), 2); | ||
String first = tla.getPassedTests().get(0).getName(); | ||
String second = tla.getPassedTests().get(1).getName(); | ||
Assert.assertTrue("f".equals(first) || "g".equals(first)); | ||
Assert.assertTrue("f".equals(second) || "g".equals(second)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
v=5.9beta | ||
|
||
javac -cp ~/java/TestNG/testng-${v}-jdk15.jar:$CLASSPATH A.java B.java -d . | ||
jar cvf withtestngxml.jar testng.xml test | ||
jar cvf withouttestngxml.jar test | ||
|
||
java -cp ~/java/TestNG/testng-${v}-jdk15.jar:$CLASSPATH org.testng.TestNG -testjar withtestngxml.jar | ||
java -cp ~/java/TestNG/testng-${v}-jdk15.jar:$CLASSPATH org.testng.TestNG -testjar withouttestngxml.jar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" > | ||
|
||
<suite name="Single" verbose="10"> | ||
|
||
|
||
<test name="test2"> | ||
<classes> | ||
<class name="test.jar.A" /> | ||
</classes> | ||
</test> | ||
</suite> | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters