Intellij"java:包org.junit不存在" [英] Intellij "java: package org.junit does not exist"

查看:98
本文介绍了Intellij"java:包org.junit不存在"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行测试时,出现以下错误:我在Google上查找后,发现在Google上有东西,但这无济于事.

When i try to run my test i get the following Errors: I looked up on google and found somthing on google but this didn't help.

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());
}
}

整个项目的屏幕截图

运行配置

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

Dependencies i.stack.imgur. com/OiQWU.png (Can't post more than 2 links)

推荐答案

我遇到了同样的问题.为了修复它,我必须为我的项目打开模块设置,然后手动添加jar依赖项 junit-4.12.jar hamcrest-core-1.3.jar IntelliJ安装lib目录.

I had the same problem. In order to fix it I had to Open Module Settings for my project and manually add jar Dependencies junit-4.12.jar and hamcrest-core-1.3.jar which are contained in the IntelliJ installation lib directory.

这篇关于Intellij"java:包org.junit不存在"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆