当我尝试运行测试时,出现以下错误:
我在Google上查找后,发现在Google上有东西,但这没有帮助。

Error:(3, 24) java: package org.junit does not exist
Error:(3, 1) java: static import only from classes and interfaces
Error:(5, 17) java: package org.junit does not exist
Error:(6, 17) java: package org.junit does not exist
Error:(12, 10) java: cannot find symbol
    symbol:   class Before
    location: class edu.kit.ipd.swt1.SimpleEditMeTest
Error:(17, 10) java: cannot find symbol
    symbol:   class Test
    location: class edu.kit.ipd.swt1.SimpleEditMeTest
[...]


我的测试代码:

package edu.kit.ipd.swt1;
import static org.junit.Assert.assertNotNull;
import org.junit.Before;
import org.junit.Test;

public class SimpleEditMeTest {
private EditMe editMe;
@Before
public void setUp() throws Exception {
    editMe = new EditMe();
}
@Test
public void test() {
    assertNotNull(editMe.getFoo());
}
}


Screenshot of the whole project

Run configurations

依赖项i.stack.imgur。 com / OiQWU.png(最多发布2个链接)

最佳答案

我有同样的问题。为了修复它,我必须为我的项目打开模块设置,并手动添加IntelliJ安装lib目录中包含的jar依赖项junit-4.12.jarhamcrest-core-1.3.jar

10-05 19:02