我正在尝试使用Intellij和TestNG构建回归套件,不知道为什么会发生这种情况。当我尝试运行它时,我得到了这些:
我的文件结构只是:
@NgModule
java文件中的代码如下:
homepage.java 包com.site.homepage;
providers: [
{ provide: LocationStrategy, useClass: HashLocationStrategy }
]
urlData.java
AutoSuite/
|-.idea/
|- out/
|- src/
|-- com/
|--- site/
|------ data/
|--------- urlData.java
|------ homepage/
|--------- Homepage.java
|- tst/
|-- com/
|--- site/
|------ homepage/
|--------- HomepageTest.java
|- AutoSuite.iml
|- External Libraries/
HomePageTest.java
public class Homepage {
public String siteTitle() {
return "site.com/";
}
}
我想也许我需要在package com.site.data;
public class urlData {
private static String DEV_WEB = "site.com/";
public String returnPROD(){ return DEV_WEB; }
}
下面的testng.xml文件,但即使在package com.site.homepage;
import com.site.homepage.Homepage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.*;
public class HomepageTest {
private WebDriver driver;
Homepage homepage;
String titleTag;
@AfterClass
public void afterClass() {
driver.quit();
}
@BeforeMethod
public void setUp() {
driver = new FirefoxDriver();
}
@AfterMethod
public void tearDown() {
driver.close();
}
@BeforeTest
public void initStringsAndObjects() {
homepage = new Homepage();
titleTag = "Site title tag";
}
@Test (priority = 1, groups={"Layout"})
public void testSiteTitle() {
driver.get(homepage.siteTitle());
Assert.assertTrue(driver.getTitle().equals(titleTag));
}
@AfterTest
public void cleanup() {
titleTag = null;
homepage = null;
}
}
下添加它之后我也会收到错误。所以我删除了它。
然后我通过选择AutoSuite/
下的文件来确保我在依赖项中测试了它。
我错过了什么?