我遵循了这些步骤,并且能够使用Intellij代码洞察力对TestCase
进行编码。
在shell中,我执行了以下操作
mkdir so33987661
mkdir so33987661/src/
mkdir so33987661/src/test
mkdir so33987661/src/test/java
cd so33987661
vi pom.xml
我的pom.xml
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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>org.so33987661</groupId>
<artifactId>my-project</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
返回Intellij,选择文件菜单,新建,现有来源的项目。
打开so33987661/pom.xml
文件。
通过单击下一步直到创建项目,接受其余屏幕的默认设置。
导航到src/test/java
文件夹并创建新的测试和代码,代码,代码。
import org.junit.Test;
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
public class BookSearchTest {
@Test
public void testIt() throws Exception {
// todo: testIt()!
}
}
我遇到了同样的问题。打开您的pom.xml,找到“ junit”。查看范围值,也许是“测试”。如果您在主程序包中导入junit,则intellij的想法将引发错误,但不会使日蚀。在适当的范围内使用junit可以解决问题。我已修正错误。
#1检入设置->构建,执行,部署->构建工具-> maven,是否正确设置了“用户设置文件”和(如果使用本地存储库)“本地存储库”路径。 >
#2
检查设置->构建,执行,部署->编译器-> Java编译器是否期望目标字节码版本。 (有时在添加新的依赖项后,Intelli会将其设置为1.5)#3
在项目设置中(默认快捷键ctrl + alt + shift + s)项目设置->项目ProjectSDK应该指向正确的目的地
项目语言级别应为您使用的版本
在项目设置->模块中