【发布时间】:2018-06-18 13:12:17
【问题描述】:
我是 Intellij IDEA 的新手。我正在尝试将 jUnit 注释 @Before 和 @After 用于我的 selenium 测试。即使我在课堂上导入 jUnit,我也无法使用注释。有什么帮助吗?
package Config;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
public class browserConfig {
public static WebDriver driver = null;
public static Properties config = new Properties();
public static FileInputStream fis;
@Before
public void initBrowser(){
if (driver ==null){
try{
fis = new FileInputStream(System.getProperty("user.dir") + "//src//main//java//Config//config.properties");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
【问题讨论】:
-
你使用的依赖是什么?
-
为什么是“if driver == null”?该检查违背了@Before 注释的目的
-
当您点击“构建项目”时,IntelliJ 会抱怨吗?
-
@Pooya 我在构建项目中收到以下错误:错误:(10、17)java:包 org.junit 不存在错误:(11、17)java:包 org.junit 不存在错误:(19、6)java:找不到符号符号:类之前的位置:类Config.browserConfig
-
@UzIT 这意味着你的依赖有问题
标签: java intellij-idea junit