I have a custom test framework that runs all the tests in my product.
I'm now extending this framework to add support for TestNG tests. To
do this I need to run TestNG programatically, so following the
instructions in the documentation I wrote the following simple piece
of code as a proof of concept. I'm going to add some custom listeners
that will do some deeper integration with my test runner later on,
once I get a basic test running.
TestMeTestNG is a simple test that doesn't do much.
public class TestMeTestNG {
@Test
public void f() {
assert 1 == 1;
}
}
When I run TestMeTestNG using the eclipse plugin (right-click, Run as -
> TestNG Test) then the test executes and passes as expected.
Then I moved on to trying to get this test to run from some java
code.
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
public class TestRunner {
public static void main(String[] args) {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { TestMeTestNG.class });
testng.addListener(tla);
testng.run();
}
}
Then I run my code (right-click, Run as, Java Application) and I get a
NPE
Exception in thread "main" java.lang.NullPointerException
at org.testng.TestNG.runSuitesLocally(TestNG.java:884)
at org.testng.TestNG.run(TestNG.java:818)
at com.openet.testng.TestRunner.main(TestRunner.java:12)
I'm using :
Eclipse Helios (Build 20100617-1415)
CentOS 5.2 (64-bit)
I installed the testng eclipse plugin from the eclipse market place.
Looks like that installed 5.14.3beta
I've got a few questions,
1, what am I doing wrong in my TestRunner class
2, where can I get the source code for 5.14.3beta?
3, Is there a "stable" version I should be using instead of a beta and
if so, where can I get that?
I don't see any tags in svn at
http://testng-eclipse.googlecode.com/svn
for this version. There's only the trunk version, so when I try to
step into the code in a debugger and see what's causing the NPE
there's a difference between the source and the .class file, so the
line numbers don't match up, which makes debugging this issue
difficult