My IntelliJ IDEA sees the JUnit 4 Maven dependencies.
But does not resolve any symbol coming from these dependencies
Any idea?
My IntelliJ IDEA sees the JUnit 4 Maven dependencies.
But does not resolve any symbol coming from these dependencies
Any idea?
I followed these steps and was able to code a TestCase
with Intellij code insight.
In a shell, I did the following
mkdir so33987661
mkdir so33987661/src/
mkdir so33987661/src/test
mkdir so33987661/src/test/java
cd so33987661
vi pom.xml
My 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>
Back to Intellij, choose File menu, New, Project from Existing Sources.
Open the so33987661/pom.xml
file.
Check the Import Maven Projects Automatically.
Accept the defaults for the rest of the screens by clicking Next until the project is created.
Navigate to the src/test/java
folder and create a new test and code, code, code.
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()!
}
}
I encountered the same problem. Open your pom.xml, find "junit". See scope value, maybe 'test'. if u import junit in main package, intellij idea will throw error, but not eclipse. Use junit in right scope can solve the problem. I fixed my error.
# 1 check in settings -> build, execution, deployment -> build tools -> maven, if "User settings file" and (if you are using local repo) "Local repository" paths are set correctly.
# 2 check in settings -> build, execution, deployment -> compiler -> java compiler if target bytecode version is that you expecting. (sometimes after adding new dependency Intelli is setting it to 1.5)
# 3 in project settings (default shortcut ctrl+alt+shift+s) project settings -> project
ProjectSDK should point to correct destination
Project language level should be version that you are using
in project settings -> modules Language Level should be version that you are using