Option [Run –> Run As –> TestNG] Test is not coming

5,253 views
Skip to first unread message

A B

unread,
Oct 9, 2012, 1:21:53 AM10/9/12
to webd...@googlegroups.com
I have configured TestNG with Eclipse. I created a script with TestNG annotation.
[Run –> Run As –> TestNG] Test is not displayed, it is showing [Run As -> Java Application].

Cheers,
A B
URL - www.automation.lifegoeasy.com

Gaurang shah

unread,
Oct 9, 2012, 7:09:53 AM10/9/12
to webd...@googlegroups.com
Are you sure you have used TestNG annotation. Check the import files, by mistake you might has used JUnit Annotation. 

darrell

unread,
Oct 10, 2012, 1:08:34 AM10/10/12
to webd...@googlegroups.com
If you have a class with "public static void main(String[] args)" method and no @Test annotation it will not have a TestNG run option. For example,

class Foo {
    public static void main(String[] args) {
        // do nothing
    }
}

This will give you Run->Run As->Java Application. If it has the @Test annotation it can be run as a TestNG class. For example,

import org.testng.annotations.Test;

class Foo {
    @Test
    public void main(String[] args) {
        // do nothing
    }
}

Note that the method is NOT static. This will give you Run->Run As->TestNG. If it matches both requirements, you will have both run options. For example,

import org.testng.annotations.Test;

class Foo {
    @Test
    public static void main(String[] args) {
        // do nothing
    }
}

This class has the correct method to be a Java Application but it also has the minimum requirements for a TestNG class. So the Run menu will have:

Run->Run As->Java Application
Run->Run As->TestNG

Darrell
Reply all
Reply to author
Forward
0 new messages