dependsOnMethods failure

839 views
Skip to first unread message

Felipe Knorr Kuhn

unread,
Jun 10, 2011, 7:03:06 PM6/10/11
to testng...@googlegroups.com
Hi Cédric,

I have a test method annotated like this:

@Test(description="Do something", dependsOnMethods = { "com.example.OtherClass.method2test" })

and I'm getting the following error:

org.testng.TestNGException:
com.example.DoesSomethingTestCase.doSomethingTest() is depending on method public void com.example.OtherClass.method2test(org.testng.ITestContext), which is not annotated with @Test

however, it is:

@Test(description="Creates entities needed by other tests")
    public void method2test(ITestContext context)

Both classes extend a BaseTest class.

I tried annotating BaseTest but it didn't work as well.

Is this a bug or working as intended?

Using   TestNG    6.0.1.20110602_1209

Thanks,

FK

JJ

unread,
Jun 11, 2011, 12:17:22 AM6/11/11
to testng...@googlegroups.com
Hi,
I am trying to run Testng programatically, I have an AllTests.java in which I create the testng.xml dynamically and pass it to TestNG to run. When I run AllTests.java directory, the tests run fine but fails when I try to run through Ant.
public class AllTests {
  public static void main(String[] args) throws Exception {
    TestNG myTestNG=new TestNG();
    List<XmlSuite> testSuites=new ArrayList<XmlSuite>();
    testSuites.add(createXmlSuite());   	
    myTestNG.setXmlSuites(testSuites);
    myTestNG.setOutputDirectory("c://temp");
    myTestNG.run();  		
}
Exception thrown while running it through Ant.
java.lang.NullPointerException
	at org.testng.internal.PoolService.isFinished(PoolService.java:148)
	at org.testng.internal.PoolService.submitTasksAndWait(PoolService.java:104)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1143)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:137)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:121)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:619)
Any ideas would be great! Thanks in advance
Regards, Jeganathan.

Cédric Beust ♔

unread,
Jun 11, 2011, 1:18:23 AM6/11/11
to testng...@googlegroups.com
Hi Jeganathan,

I'll look into it but I will probably need a project to reproduce this problem.

-- 
Cédric




--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Cédric Beust ♔

unread,
Jun 13, 2011, 1:18:45 PM6/13/11
to testng...@googlegroups.com
Hi Felipe,

Is "com.example.OtherClass" mentioned in your <classes> tag?

-- 
Cédric




--

Felipe Knorr Kuhn

unread,
Jun 13, 2011, 5:25:32 PM6/13/11
to testng...@googlegroups.com
Hi Cédric,

In this particular case, I'm not launching it via testng.xml, I'm right clicking -> run as TestNG Test

Thanks,

FK

2011/6/13 Cédric Beust ♔ <ced...@beust.com>

Cédric Beust ♔

unread,
Jun 13, 2011, 5:45:26 PM6/13/11
to testng...@googlegroups.com
On Mon, Jun 13, 2011 at 2:25 PM, Felipe Knorr Kuhn <fkn...@gmail.com> wrote:
Hi Cédric,

In this particular case, I'm not launching it via testng.xml, I'm right clicking -> run as TestNG Test

That's the problem. When you do this, TestNG only knows about the class you are clicking on and it doesn't know which other classes should be included for introspection. Therefore, it doesn't know about that other class that contains your dependency.

You can fix this by creating a short suite file with your two classes:

name: SingleSuite


tests:

  - name: Test1

    classes:

      - name: test.jar.Class1

      - name: test.jar.Class2

 


-- 
Cédric

Felipe Knorr Kuhn

unread,
Jun 14, 2011, 12:20:55 AM6/14/11
to testng...@googlegroups.com
Thanks for clarifying that, Cédric.

I was hoping that the plugin could somehow detect the dependencies by reading the annotation and compile them before running the class I just clicked on. 

This would be handy to have somewhat self-contained tests to be run from Eclipse, in situations where the developers fix a bug in one feature/scenario and you want to run just that one test that you know would fail.

Thanks,

FK

2011/6/13 Cédric Beust ♔ <ced...@beust.com>
On Mon, Jun 13, 2011 at 2:25 PM, Felipe Knorr Kuhn <fkn...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages