我正在尝试在我的testng测试上运行mvn clean verify。该测试在类文件中运行并通过。当它们真正通过时,我看不到为什么我的构建由于teswt故障而失败。然后告诉我我有测试失败。我的Surefire插件输出显示测试已通过。我在做什么错了?
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 12.316 s - in TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.384 s
[INFO] Finished at: 2020-05-10T14:55:21+01:00
[INFO] Final Memory: 18M/166M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project dotdotloans: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\Peter\IdeaProjects\dotdotloanstestng\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] Error occurred in starting fork, check output in log
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: Error occurred in starting fork, check output in log
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:623)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1161)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1002)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:848)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Process finished with exit code 1
我的POM文件
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>co.uk.dotdotloans</groupId>
<artifactId>dotdotloans</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.11.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<systemPropertyVariables>
<browser>chrome</browser>
<!-- <forkCount>0</forkCount>-->
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>fullregression.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
我的代码
public class HomePage {
static{
System.setProperty("webdriver.chrome.driver", "C:/webdrivers/chromedriver81/chromedriver.exe");
}
WebDriver driver = new ChromeDriver();
String urlBase = "http://www.dotdotloans.co.uk";
@BeforeTest
public void beforeTest() {
driver.get(urlBase);
driver.manage().window().maximize();
}
@Test
public void verify36monthloan3250() {
driver.findElement(By.cssSelector("div.flex-xs:nth-child(2) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > a:nth-child(3)")).click();
String calcLoan = driver.findElement(new By.ByCssSelector(".flex-col-11-md > h1:nth-child(1)")).getText();
Assert.assertEquals(calcLoan, "Calculate your loan");
//move slider 70%
WebElement slider = driver.findElement(By.xpath("//div[@class='noUi-origin']/div"));
Actions move = new Actions(driver);
Action action = move.dragAndDropBy(slider, 130, 0).build();
action.perform();
String borrow = driver.findElement(new By.ByXPath("/html/body/div[3]/div[3]/div/div/div[2]/div/div/div[1]/div[1]/span")).getText();
Assert.assertEquals(borrow, "£3250");
//double click plus button code.
// driver.findElement(By.cssSelector(".fa-plus")).click();
// Actions action = new Actions(driver);
// WebElement link = driver.findElement(By.xpath("//*[@id=\"calc_slider-plus\"]"));
// action.doubleClick(link).perform();
// confirm monthly repayment
String repayment = driver.findElement(new By.ByCssSelector(".calc_values > li:nth-child(1) > span:nth-child(2)")).getText();
Assert.assertEquals(repayment, "£197.26");
// credit charge 2 decimal places
String creditcharge = driver.findElement(new By.ByCssSelector(".calc_values > li:nth-child(2) > span:nth-child(2)")).getText();
Assert.assertEquals(creditcharge, "£3851.25");
//total to pay 2 decimal places
String totaltopay = driver.findElement(new By.ByCssSelector(".calc_values > li:nth-child(3) > span:nth-child(2)")).getText();
Assert.assertEquals(totaltopay, "£7101.25*");
//APR
String apr = driver.findElement(new By.ByCssSelector(".calc_values > li:nth-child(4) > span:nth-child(2)")).getText();
Assert.assertEquals(apr, "79.6%");
//Click Apply now
driver.findElement(By.cssSelector("a.btn:nth-child(6)")).click();
//verify string has 3250 and 36 months
String verifyloan = driver.findElement(new By.ByCssSelector(".edit-wrapper > h4:nth-child(1)")).getText();
Assert.assertEquals(verifyloan, "You have chosen to borrow £3250 for 36 months");
}
@AfterTest
public void AfterTest() {
driver.quit();
}
}