Maven的测试失败,但在詹金斯同样的测试succeded
问题描述:
这是我的代码:Maven的测试失败,但在詹金斯同样的测试succeded
package example;
import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
public class NewTest {
private WebDriver driver;
@Test
public void f() {
driver.get("http://demo.guru99.com/selenium/guru99home/");
String title = driver.getTitle();
AssertJUnit.assertTrue(title.contains("Demo Guru99 Pageee"));
System.out.println("Success");
}
@BeforeTest
public void beforeTest() {
String exePath = "/Users/enislavmollov/Downloads/chromedriver";
System.setProperty("webdriver.chrome.driver", exePath);
driver = new ChromeDriver();
}
@AfterTest
public void afterTest() {
driver.quit();
}
}
怎么可能,以及如何使詹金斯给予正确的结果作为一个在Eclipse
答
Maven模型的Eclipse模拟不是100%正确的。值得注意的是,Eclipse并没有区分src/main/java和src/test/java--它们都在大锅饭中一起使用。 Maven的确如此。
测试类必须将放置在src/test/java中,以便由maven-surefire-plugin调用。
+0
我的课程在src/test/java下:https://imgur.com/a/G4Cj1.png – EnislavMollov
+0
请让一个MCVE演示这种行为,并将它放在例如github上。 https://stackoverflow.com/help/mcve –
而实际的测试是? –
请看我上面的代码,我刚添加它。 – EnislavMollov
我建议多看看'driver.get()'返回的内容。 –