Re: [testng-users] Compilation failure: package org.testng does not exist (maven+testng)

7,172 views
Skip to first unread message

Tomek Kaczanowski

unread,
Sep 13, 2012, 12:01:11 PM9/13/12
to testng...@googlegroups.com
Hi Ramesh,

are your classes in src/test/java?

--
Regards / Pozdrawiam
Tomek Kaczanowski
http://practicalunittesting.com


2012/9/13 Ramesh <rameshk...@gmail.com>:
> Hi ,
>
> here I attached my pom.xml
>
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>Mavenintergation</groupId>
> <artifactId>Mavenintergation</artifactId>
> <version>0.0.1-SNAPSHOT</version>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> </properties>
> <dependencies>
> <dependency>
> <groupId>org.seleniumhq.selenium</groupId>
> <artifactId>selenium-java</artifactId>
> <version>2.20.0</version>
> </dependency>
> <dependency>
> <groupId>org.testng</groupId>
> <artifactId>testng</artifactId>
> <version>6.1.1</version>
> <scope>test</scope> < !-- here i added the Scope i got an error
> package org.testng -->
> </dependency>
> <dependency>
> <groupId>com.google.inject</groupId>
> <artifactId>guice</artifactId>
> <version>2.0</version>
> </dependency>
>
> <dependency>
> <groupId>org.uncommons</groupId>
> <artifactId>reportng</artifactId>
> <version>1.1.2</version>
> <scope>test</scope>
> <exclusions>
> <exclusion>
> <groupId>org.testng</groupId>
> <artifactId>testng</artifactId>
> </exclusion>
> </exclusions>
> </dependency>
> </dependencies>
>
> <build>
> <pluginManagement>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <configuration>
> <source>1.6</source>
> <target>1.6</target>
> </configuration>
> </plugin>
> </plugins>
> </pluginManagement>
> </build>
>
> <profiles>
> <profile>
> <id>selenium-tests</id>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <version>2.12</version>
> <configuration>
> <skip>true</skip>
> <properties>
> <property>
> <name>usedefaultlisteners</name>
> <value>false</value>
> </property>
> <property>
> <name>listener</name>
>
> <value>org.uncommons.reportng.HTMLReporter,
>
> org.uncommons.reportng.JUnitXMLReporter</value>
> </property>
> </properties>
> <workingDirectory>target/</workingDirectory>
> </configuration>
> <executions>
> <execution>
> <id>start-testing</id>
> <phase>integration-test</phase>
> <goals>
> <goal>test</goal>
> </goals>
> <configuration>
> <skip>false</skip>
> <suiteXmlFiles>
>
> <suiteXmlFile>testng.xml</suiteXmlFile>
> </suiteXmlFiles>
> <includes>
> <include>**/*.java</include>
> </includes>
> </configuration>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> </profile>
> </profiles>
>
> </project>
>
> mvn integration-test
>
> i got an error [INFO] Compilation failure
> package org.testng does not exist
>
> thanks in advanced
> Ramesh
>
> --
> You received this message because you are subscribed to the Google Groups
> "testng-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/testng-users/-/b3UWvj9eQkIJ.
> 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.

Krishnan Mahadevan

unread,
Sep 13, 2012, 1:29:37 PM9/13/12
to testng...@googlegroups.com
I think I already responded to this query when it was posted on the webdriver forums. Let me re-iterate again. 
I think the problem is with the scope. Since u specified the scope as test, Maven would force java to refer to the TestNG jar only when the unit tests are running. But in your case it looks like TestNG jar needs to be referred even at the compile phase itself. So can you please get rid of the scope tag and retry? [ By default scope is always "compile" in the maven world]



scope>test</scope> < !-- here i added the Scope i got an error  package org.testng -->

--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

Krishnan Mahadevan

unread,
Sep 14, 2012, 1:43:29 PM9/14/12
to testng...@googlegroups.com
I dont think you testng suite file is even being referred to when you do a mvn test -Dtest=classname
Which explains the null value for your parameter and hence the NumberFormatException!

On Friday, September 14, 2012, Ramesh wrote:
Hello All ,

Thanks for reply.

my sources are placed in to src/main/java, now I moved my sources in to src/test/java now works fine .

but I faced other problem ,

command line :  mvn -Dtest=classname test

Tests run: 17, Failures: 1, Errors: 0, Skipped: 16, Time elapsed: 0.516 sec <<< FAILURE!
setupBeforeSuite(org.openqa.selenium.example.TestNGTesting)  Time elapsed: 0 sec  <<< FAILURE!
java.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Integer.java:417)
    at java.lang.Integer.parseInt(Integer.java:499)
    at org.openqa.selenium.example.CommonUtil.registerDriver(CommonUtil.java:64)
    at org.openqa.selenium.example.TestNGTesting.setupBeforeSuite(TestNGTesting.java:20)

=========================================================================
INPUT :

in testng.xml  pass parameter like below  :

<parameter name="selectrow" value ="2"/>

in JAVA ,

this.numberOfProcess = Integer.parseInt(context.getCurrentXmlTest().getParameter("selectrow"));

can you help why error thrown
java.lang.NumberFormatException

Thanks & Regards
Ramesh Kumar
    <profiles>
        <profile>
            <id>selenium-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.12</version>
                        <configuration>
                            <skip>true</skip>
                            <properties>
                                <property>
                                    <name>usedefaultlisteners</name>
                                    <value>false</value>
                                </property>
                                <property>
                                    <name>listener</name>
                                    <value>org.uncommons.reportng.HTMLReporter,
                                        org.uncommons.reportng.JUnitXMLReporter</value>
                                </property>
                            </properties>
                            <workingDirectory>target/</workingDirectory>
                        </configuration>
                        <executio
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/ae9Gzg_41N8J.

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.

Ramesh

unread,
Sep 18, 2012, 4:12:26 AM9/18/12
to testng...@googlegroups.com
Hello guys,

I want to run single test class from command line using Maven and TestNG

mvn -Dtest=ClassName test works but fetching Parameters from testng.xml  returns  null


when config is,


    <profiles>
        <profile>
            <id>selenium-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.12.3</version>
                     <configuration>
                      <skip>true</skip>          
                        </configuration>
                     <executions>
                            <execution>
                                <id>start-testing</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <skip>false</skip>
                              
   <!--   <suiteXmlFiles>
                                        <suiteXmlFile>testng.xml</suiteXmlFile>
                                    </suiteXmlFiles>      -->                            
                                      <includes>
                                        <include>**/*.java</include>
                                    </includes>                                
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

What's wrong with my configuration? Is there a way to run a single test
outside of those defined in pom.xml?

thanks & Regards
Ramesh kumar

To unsubscribe from this group, send email to testng-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply all
Reply to author
Forward
0 new messages