Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Bamboo

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

186 views 4 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you