Atlassian Bamboo Logs: [testng] 在类路径中找不到类:com.vaannila.domai



我遇到了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>

这是我的用户测试.java类:

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
public void beforeTest() throws Exception {
//giving the location where selenium chrome driver is located in my file system
System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
//if chrome driver has to work on a CI server, then we have to additionally install xvfb and reboot the server. So, we are going to circumvent all that and leverage chrome sans GUI via headless mode.
ChromeOptions co = new ChromeOptions();
//Now we have to add headless arguments to our chrome driver
co.addArguments("--headless");
co.addArguments("--start-maximized");
//initializing a chrome driver with driver object
driver = new ChromeDriver(co);
//asking the chrome driver to implicitly wait for 5 seconds before moving on
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//setting the value of baseUrl variable
baseUrl = "http://xx.xx.xx.xx:9999/myuser/userRegistration.htm";
}  
@Test
public void userreg() throws InterruptedException{
//this step opens up chrome browser with the aforementioned application
driver.get(baseUrl);
//getting web elements of name and password. Then we send info to those via sendKeys()
System.out.println("Getting ready to register a user by getting details from them");
WebElement name = driver.findElement(By.id("name"));
WebElement password = driver.findElement(By.id("password"));
name.sendKeys("aditya");
password.sendKeys("aditya123");
System.out.println("fields set...");
//getting radio element buttons in our user registration webpage
WebElement radio1 = driver.findElement(By.id("gender1"));
WebElement radio2 = driver.findElement(By.id("gender2"));
WebElement radio3 = driver.findElement(By.id("gender3"));
//toggling radio buttons
radio1.click();
System.out.println("Radio 1 button is selected");
radio2.click();
System.out.println("Radio 2 button is selected");
radio3.click();
System.out.println("Radio 3 button is selected");
//Selecting country from Drop down ( Used Id to identify the element )
Select options = new Select(driver.findElement(By.id("country")));
//selecting India option via select by visible text
options.selectByVisibleText("India");
//Using sleep command so that the change is visible
Thread.sleep(2000);
//selecting USA via select by index mechanism
options.selectByIndex(2);
//using sleep command so that the change is visible
Thread.sleep(2000);
//Print all the options for the selected drop down and select one option of your choice
// Get the size of the Select element
List<WebElement> optionsize = options.getOptions();
int iListSize = optionsize.size();
//using for loop to go through all options in drop down
for(int i=0;i<iListSize;i++) {
//storing the value of an option sValue variable
String sValue = options.getOptions().get(i).getText();
//printing out the variable
System.out.println(sValue);
// Putting a check on each option that if any of the option is equal to 'USA' then select it
if(sValue.equals("India")) {
options.selectByIndex(i);
break;
}
}
//Getting the textarea element of our webpage
WebElement textbox = driver.findElement(By.id("aboutYou"));
textbox.sendKeys("I am a good boy who is looking to learn java");
//getting checkbox elements of our webpage and toggling them
WebElement option1c = driver.findElement(By.id("community1"));
option1c.click();
if(option1c.isSelected()) {
System.out.println("Checkbox is toggled on");
} else {
System.out.println("Checkbox is toggled off");
}
//selecting another element (mailing list option) in our webpage
WebElement mail = driver.findElement(By.id("mailingList1"));
mail.click();
if(mail.isSelected()) {
System.out.println("Checkbox is toggled on");
} else {
System.out.println("Checkbox is toggled off");
}
//getting the submit option of our webpage
WebElement query = driver.findElement(By.cssSelector("input"));
query.click();
System.out.println("done submitting...");
//clearing all the fields of our webpage
name.clear();
password.clear();
textbox.clear();
System.out.println("Fields cleared...");
}
@AfterTest
public void afterTest() throws Exception {
driver.close();
}
}

这是我的构建.xml文件:

<?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>

我对这个错误完全空白。我已经参考了这个链接,但我的构建在 eclipse IDE 和 cmd 中没有出现故障.exe但它在 Atlassian 竹子 CI 服务器中失败并出现上述错误。所以这个问题和我的问题是完全不同的。我无法清理并在 CI 服务器中进行构建。

我需要有关解决此错误的帮助。

哎呀...我错过了$接近{build}的目标tests

很抱歉给您带来麻烦。

给每个人的一个指针:非常小心类名,变量 替换等一个简单而愚蠢的错误可以带来你的进步 停滞不前,这种错误很难发现。

问候

阿迪亚

相关内容

  • 没有找到相关文章

最新更新