[英]Cannot resolve symbol 'Before' - Intellij jUnit
I am new to Intellij IDEA. 我是Intellij IDEA的新手。 I'm trying to use jUnit annotations @Before and @After for my selenium tests.
我正在尝试对硒测试使用jUnit批注@Before和@After。 Even though I'm importing jUnit in my class, I 'm not able to use the annotations.
即使我在类中导入jUnit,也无法使用注释。 Any help?
有什么帮助吗?
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();
}
Your test should be in the test folder, otherwise idea will ignore the test annotations. 您的测试应位于测试文件夹中,否则提示将忽略测试注释。 Make sure the class is placed in the src/test/ folder.
确保将类放在src / test /文件夹中。 Also check in Project Settings -> Modules that your tests folder is present in the structure and has green color (marked as Tests).
还要在项目设置->模块中检查您的测试文件夹是否存在于结构中并具有绿色(标记为测试)。 If it is missing - add it to the modules and mark as Tests.
如果缺少-将其添加到模块中并标记为“测试”。
If you are using gradle to build in Intellij, try adding this to build.gradle. 如果您正在使用gradle构建Intellij,请尝试将其添加到build.gradle。
testCompile('org.springframework.boot:spring-boot-starter-test')
If you aren't using gradle do something similar with whatever controls your dependencies. 如果您不使用gradle,请对您的依赖项进行任何类似的控制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.