Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,735
Community Members
 
Community Events
176
Community Groups

Atlassian Bamboo Logs: [testng] Cannot find class in classpath: com.vaannila.domain.UserTest

Hi Everyone

 

I was trying to build a sample war file and deploy it on a tomcat server. But, I'm facing this error of testNG unable to find class in the classpath. But I am pretty sure I have mentioned the right class path.

Here is my testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="User Registration suite 1" verbose="1" >
  <test name="Regression suite 1" >
    <classes>
      <class name="com.vaannila.domain.UserTest"/>
    </classes>
 </test>
</suite>

Here is my UserTest.java class:

package com.vaannila.domain;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.Select;
//Java imports
import java.util.concurrent.TimeUnit;
import java.util.List;

public class UserTest {
    private WebDriver driver;
    private String baseUrl;

 @BeforeTest
 @Test
@AfterTest
}

Here is my build.xml file:

<?xml version="1.0" ?>
<project name="UserRegistrationAnt" default="war" basedir="." xmlns:sonar="antlib:org.sonar.ant">

    <!-- Beginning of project dir definition -->
    <property name="testng.xml.file" value="testng.xml" />
    <property name="basedir" location="." />
    <property name="src" location="${basedir}/src" />
    <property name="lib" location="${basedir}/WebContent/WEB-INF/lib" />
    <property name="build" location="${basedir}/target/classes" />
    <property name="war-file" location="${basedir}/dist" />
    <property name="test-reports" location="{basedir}/test-reports" />
    <!-- End of project dir definition -->
    <!-- Beginning of sonar properties definition -->
    <property name="sonar.host.url" value="http://xx.xx.x.xxx:9000" />
    <property name="sonar.projectKey" value="9bc89a6e0d659c33ef4b61b27dc486b1f9075241" />
    <property name="sonar.projectName" value="9bc89a6e0d659c33ef4b61b27dc486b1f9075241" />
    <property name="sonar.projectVersion" value="1.0" />
    <property name="sonar.language" value="java" />
    <property name="sonar.sources" value="${src}" />
    <property name="sonar.java.binaries" value="${build}" />
    <property name="sonar.sourceEncoding" value="UTF-8" />
    <!-- End of sonar properties definition -->


    <!-- Definition of external dependencies location -->
    <path id="compile.classpath">
        <fileset dir="${lib}">
                        <include name="*.jar"/>
                </fileset>
        </path>

    <!-- Making dirs for compiled, war file and test reports-->
        <target name="init">
        <mkdir dir="${build}"/>
        <mkdir dir="${war-file}" />
        <mkdir dir="${test-reports}" />
    </target>

    <!-- Compilation of our source and test code -->
        <target name="compile" depends="init" >
        <javac destdir="${build}" debug="true" srcdir="${src}" classpathref="compile.classpath" includeantruntime="false" />
        </target>

    <!-- Execution of testng -->
    <taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="compile.classpath" />
    <target name="tests" depends="compile">
        <testng outputdir="${test-reports}" classpathref="compile.classpath" haltOnFailure="true">
            <classpath location="{build}" />
            <xmlfileset dir="${basedir}" includes="${testng.xml.file}" />
        </testng>
    </target>

    <!-- Execution of sonar analysis -->
    <target name="sonar" depends="compile">
        <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
            <!-- update the following line or put sonar-ant-task-*.jar in $ANT_HOME/.ant/lib folder -->
            <classpath path="/opt/ant/apache-ant-1.10.5/lib/sonarqube-ant-task-2.5.jar" />
        </taskdef>
        <!-- Execute SonarQube scanner for ant analysis -->
        <sonar:sonar />
    </target>

        <target name="war" depends="compile">
        <war destfile="{war-file}/AntExample.war" webxml="WebContent/WEB-INF/web.xml">
            <fileset dir="${basedir}/WebContent"/>
            <lib dir="${lib}"/>
            <classes dir="${build}"/>
                </war>
        </target>

        <!--target name="clean">
                <delete dir="dist" />
                <delete dir="build" />
                <delete dir="reports" />
    </target-->

    <target name="all" depends="init, compile, tests, sonar, war" description="one single target to fire up every ant build stage" />

</project>

I am completely blank about this error, and have referred this link but my builds are happening without a glitch in eclipse IDE and cmd.exe. The build is failing in Atlassian bamboo CI server with the aforementioned error. So that issue and mine are completely different. I can't clean and do a build in a CI server.

Should I place testng jar in ANT_HOME/lib folder? Will that resolve this issue?

I need help on resolving this error.

Regards

Aditya

1 answer

It was a silly mistake on my end. I didn't insert $ before {build} in tests target.

Hi,

I am getting the same error when I run my tests from bamboo. Tried few options but not able to resolve it.

Could you please help?..I am stuck and need help immediately.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events