TestNG test does not pass

Hi,

this test passes, but not in Intellij; I have the TestNG plugin enabled

package test2;

/**
* Created with IntelliJ IDEA.
* User: mic
* Date: 18/05/13
* Time: 08:24
* To change this template use File | Settings | File Templates.
*/
import java.util.ArrayList;
import java.util.Collection;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class Test2 {

    private Collection collection;

    public Test2() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @BeforeMethod
    public void setUpMethod() throws Exception {
        collection = new ArrayList();
        System.out.println("@BeforeMethod - setUp");
    }

    @AfterMethod
    public void tearDownMethod() throws Exception {
        collection.clear();
        System.out.println("@AfterMethod - tearDown");
    }

    @Test
    public void testOneItemCollection() {
        collection.add("itemA");
        Assert.assertEquals(collection.size(), 1);
        System.out.println("@Test - testOneItemCollection");
    }

###

Inside test2 package I have testng.xml

<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="My Suite">
    <test name="Simple Test">
        <classes>
            <class name="test2.Test2"/>
        </classes>
    </test>
</suite>

###

The stack trace indicates a problem with the parameter -usedefaultlisteners but there are none in the testng run/configuration (see attached png)

/home/mic/local/jdk1.6.0_41/bin/java -ea -Didea.launcher.port=7532 -Didea.launcher.bin.path=/home/mic/idea-IU-129.400/bin -Dfile.encoding=UTF-8 -classpath /home/mic/idea-IU-129.400/plugins/testng/lib/testng-plugin.jar:/home/mic/local/jdk1.6.0_41/jre/lib/jsse.jar:/home/mic/local/jdk1.6.0_41/jre/lib/plugin.jar:/home/mic/local/jdk1.6.0_41/jre/lib/rt.jar:/home/mic/local/jdk1.6.0_41/jre/lib/deploy.jar:/home/mic/local/jdk1.6.0_41/jre/lib/jce.jar:/home/mic/local/jdk1.6.0_41/jre/lib/resources.jar:/home/mic/local/jdk1.6.0_41/jre/lib/management-agent.jar:/home/mic/local/jdk1.6.0_41/jre/lib/charsets.jar:/home/mic/local/jdk1.6.0_41/jre/lib/javaws.jar:/home/mic/local/jdk1.6.0_41/jre/lib/ext/sunjce_provider.jar:/home/mic/local/jdk1.6.0_41/jre/lib/ext/dnsns.jar:/home/mic/local/jdk1.6.0_41/jre/lib/ext/localedata.jar:/home/mic/local/jdk1.6.0_41/jre/lib/ext/sunpkcs11.jar:/home/mic/IdeaProjects/HibSQL/out/production/HibSQL:/home/mic/IdeaProjects/HibSQL/lib/hibernate-core-4.1.1.Final.jar:/home/mic/IdeaProjects/HibSQL/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar:/home/mic/IdeaProjects/HibSQL/lib/hibernate-commons-annotations-4.0.1.Final.jar:/home/mic/IdeaProjects/HibSQL/lib/antlr-2.7.7.jar:/home/mic/IdeaProjects/HibSQL/lib/dom4j-1.6.1.jar:/home/mic/IdeaProjects/HibSQL/lib/javassist-3.15.0-GA.jar:/home/mic/IdeaProjects/HibSQL/lib/jboss-logging-3.1.0.GA.jar:/home/mic/IdeaProjects/HibSQL/lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar:/home/mic/local/glassfish-3.1.2.2/glassfish/modules/javax.servlet.jsp-api.jar:/home/mic/local/glassfish-3.1.2.2/glassfish/modules/javax.ejb.jar:/home/mic/local/glassfish-3.1.2.2/glassfish/modules/javax.servlet-api.jar:/home/mic/IdeaProjects/HibSQL/lib/jsf-api.jar:/home/mic/IdeaProjects/HibSQL/lib/jsf-impl.jar:/home/mic/IdeaProjects/HibSQL/lib/jstl-1.1.0.jar:/home/mic/IdeaProjects/HibSQL/lib/icefaces.jar:/home/mic/IdeaProjects/HibSQL/lib/icefaces-ace.jar:/home/mic/IdeaProjects/HibSQL/lib/icefaces-compat.jar:/home/mic/IdeaProjects/HibSQL/lib/icepush.jar:/home/mic/IdeaProjects/HibSQL/lib/poi-3.7.jar:/home/mic/IdeaProjects/HibSQL/lib/commons-beanutils.jar:/home/mic/IdeaProjects/HibSQL/lib/commons-collections.jar:/home/mic/IdeaProjects/HibSQL/lib/commons-digester.jar:/home/mic/IdeaProjects/HibSQL/lib/commons-logging.jar:/home/mic/IdeaProjects/HibSQL/lib/el-api.jar:/home/mic/IdeaProjects/HibSQL/lib/jxl.jar:/home/mic/IdeaProjects/HibSQL/lib/krysalis-jCharts-1.0.0-alpha-1.jar:/home/mic/IdeaProjects/HibSQL/lib/portletfaces-bridge-2.0.2-ice-7875.jar:/home/mic/IdeaProjects/HibSQL/lib/FastInfoset.jar:/home/mic/IdeaProjects/HibSQL/lib/el-api-2.2.1-b03.jar:/home/mic/IdeaProjects/HibSQL/lib/javax.annotation.jar:/home/mic/IdeaProjects/HibSQL/lib/javax.servlet.jar:/home/mic/IdeaProjects/HibSQL/lib/javax.servlet.jsp.jar:/home/mic/IdeaProjects/HibSQL/lib/portlet2-api.jar:/home/mic/IdeaProjects/HibSQL/lib/jstl.jar:/home/mic/IdeaProjects/HibSQL/lib/ApacheLICENSE-2.0.txt:/home/mic/IdeaProjects/HibSQL/lib/CDDL-1.0.txt:/home/mic/IdeaProjects/HibSQL/lib/MIT-LICENSE.txt:/home/mic/IdeaProjects/HibSQL/lib/NOTICE.txt:/home/mic/IdeaProjects/HibSQL/lib/openfaces.jar:/home/mic/IdeaProjects/HibSQL/lib/sac.jar:/home/mic/IdeaProjects/HibSQL/lib/jfreechart.jar:/home/mic/IdeaProjects/HibSQL/lib/jcommon.jar:/home/mic/IdeaProjects/HibSQL/lib/cssparser.jar:/home/mic/IdeaProjects/HibSQL/lib/commons-collections_2.jar:/home/mic/IdeaProjects/HibSQL/lib/openfaces-license.txt:/home/mic/IdeaProjects/HibSQL/lib/redistribution.txt:/home/mic/IdeaProjects/HibSQL/lib/commons-codec-1.3-license.txt:/home/mic/IdeaProjects/HibSQL/lib/cssparser-0.9.4-license.txt:/home/mic/IdeaProjects/HibSQL/lib/dojo-license.txt:/home/mic/IdeaProjects/HibSQL/lib/jdom-1.0-license.txt:/home/mic/IdeaProjects/HibSQL/lib/jfreechart-license.txt:/home/mic/IdeaProjects/HibSQL/lib/json-license.txt:/home/mic/IdeaProjects/HibSQL/lib/myfaces-license.txt:/home/mic/IdeaProjects/HibSQL/lib/richfaces-core-api.jar:/home/mic/IdeaProjects/HibSQL/lib/richfaces-core-impl.jar:/home/mic/IdeaProjects/HibSQL/lib/richfaces-components-ui.jar:/home/mic/IdeaProjects/HibSQL/lib/richfaces-components-api.jar:/home/mic/IdeaProjects/HibSQL/lib/lgpl.txt:/home/mic/IdeaProjects/HibSQL/lib/primefaces-3.4.1.jar:/home/mic/IdeaProjects/HibSQL/testng-5.0.jar:/home/mic/idea-IU-129.400/plugins/testng/lib/testng.jar:/home/mic/idea-IU-129.400/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain org.testng.RemoteTestNGStarter -port 52862 -d /home/mic/IdeaProjects/HibSQL -usedefaultlisteners false -socket52885 -temp /tmp/idea_testng2564164976076482919.tmp
Unknown option: -usedefaultlisteners
Usage:
[-d output-directory]
        default output directory to : test-output
[-testclass list of .class files or list of class names]
[-sourcedir a source directory]
[-target 1.4 or 1.5]
        used only with JDK1.5 to specify the annotation type used in test classes; default target: 1.5
[-groups comma-separated list of group names to be run]
        works only with -testclass
[-excludegroups comma-separated list of group names to be excluded]
        works only with -testclass
[-testrunfactory list of .class files or list of class names implementing org.testng.ITestRunnerFactory]
[-listener list of .class files or list of class names implementing org.testng.ITestListener and/or org.testng.ISuiteListener]
[suite definition files*]

For details please consult documentation.

Process finished with exit code 0


###

Thanks for any help



Attachment(s):
noparams.png
11 comments

Hi Michael,

please open the next tab Listeners and unselect "Use default reporters" checkbox. This option was not available in testng 5.0 which you use. You may configure this setting also for project default configuration so all new configurations would get the correct value.
Thanks

0

SOLVED: I removed the testng5-0.jar and the testng plugin worked with no further configuration.

0

You seem to be using TestNG 5.0? This is a very old version, update to the latest (6.8.5) and try again.

Update: sorry for the late response, which Anna has answered. I posted it two days ago but I didn't see that the forum rejected my post, and I can't seem to be able to delete it now.

0

Anna, can you let us know how you deleted the jar (location)?

0

Cedric, how do I update the testng plugin to the latest version? When I goto plugins options in IntelliJ preferences, all i see is the TestNG plugin listed as "bundled".

0

Chandra,
it's located in IDEA_INSTALLATION_HOME/plugins/testng/lib. One jar there is IDEA's plugin jar and another one is testng.jar which you have to replace with your own downloaded from testng.org as jar from maven doesn't have ability to actually start tests.
Anna

0

Hi ,
I have updated the TestNG jar to 6.8.7 in teh plugins folder and still i am getting the same error.

.RemoteTestNGStarter -port 61496 -usedefaultlisteners false -socket61497 -temp /private/var/folders/04/gknlfp254tx54j2rh2fj42nm0jy_pd/T/idea_testng1570593275897542404.tmp
Unknown option: -usedefaultlisteners
Usage: <main class> [options] The XML suite files to run
  Options:
    -configfailurepolicy               Configuration failure policy (skip or
                                       continue)
    -d                                 Output directory
    -dataproviderthreadcount           Number of threads to use when running
                                       data providers
    -excludegroups                     Comma-separated list of group names to
      ..
...

0

Please attach the full content of IDEA's console. I'd like to check the classpath. Thanks

0

Hi ,
here is the complete output from console.  Testng.jar showing in plugins folder has been renamed. It is actually 6.8.7 version.


/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -Didea.launcher.port=7532 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 12.app/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA 12.app/plugins/testng/lib/testng-plugin.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/deploy.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/dt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javaws.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jconsole.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/management-agent.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/plugin.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/sa-jdi.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/charsets.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/dnsns.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunjce_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunpkcs11.jar:All project specific Jar files here:/Users/nr/.m2/repository/org/testng/testng/6.8/testng-6.8.jar: Project specific jar files here:/Users/nr/.m2/repository/org/testng/testng/5.0/testng-5.0-jdk15.jar:Project specific jars here:/Applications/IntelliJ IDEA 12.app/plugins/testng/lib/testng.jar:/Applications/IntelliJ IDEA 12.app/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.testng.RemoteTestNGStarter -port 49866 -usedefaultlisteners false -socket49867 -temp /private/var/folders/04/gknlfp254tx54j2rh2fj42nm0jy_pd/T/idea_testng7848088838044912879.tmp
Unknown option: -usedefaultlisteners
Usage: <main class> [options] The XML suite files to run
  Options:
    -configfailurepolicy               Configuration failure policy (skip or
                                       continue)
    -d                                 Output directory
    -dataproviderthreadcount           Number of threads to use when running
                                       data providers
    -excludegroups                     Comma-separated list of group names to
                                       exclude
    -groups                            Comma-separated list of group names to be
                                       run
    -junit                             JUnit mode
                                       Default: false
    -listener                          List of .class files or list of class
                                       names implementing ITestListener or
                                       ISuiteListener
    -methods                           Comma separated of test methods
                                       Default: []
    -methodselectors                   List of .class files or list of class
                                       names implementing IMethodSelector
    -mixed                             Mixed mode - autodetect the type of
                                       current test and run it with appropriate runner
                                       Default: false
    -objectfactory                     List of .class files or list of class
                                       names implementing ITestRunnerFactory
    -parallel                          Parallel mode (methods, tests or classes)
    -port                              The port
    -reporter                          Extended configuration for custom report
                                       listener
    -suitename                         Default name of test suite, if not
                                       specified in suite definition file or source code
    -suitethreadpoolsize               Size of the thread pool to use to run
                                       suites
                                       Default: 1
    -testclass                         The list of test classes
    -testjar                           A jar file containing the tests
    -testname                          Default name of test, if not specified in
                                       suitedefinition file or source code
    -testnames                         The list of test names to run
    -testrunfactory, -testRunFactory   The factory used to create tests
    -threadcount                       Number of threads to use when running
                                       tests in parallel
    -usedefaultlisteners               Whether to use the default listeners
                                       Default: true
    -log, -verbose                     Level of verbosity
    -xmlpathinjar                      The full path to the xml file inside the
                                       jar file (only valid if -testjar was
                                       specified)
                                       Default: testng.xml


Process finished with exit code 1

0

Please remove testng 5.0 dependency from your project.

0

Thanks Anna. After removing testng 5 from classpath, it started working.

0

Please sign in to leave a comment.