Intellij似乎在Scala项目中忽略了我的JUnit测试 [英] Intellij seems to be ignoring my JUnit tests in a Scala project

查看:371
本文介绍了Intellij似乎在Scala项目中忽略了我的JUnit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Intellij的Scala项目中运行JUnit测试.尽管通过Intellij外部的sbt运行测试似乎可以正常工作,但Intellij似乎忽略了我添加的库依赖关系-也就是说,这告诉我org.junit.Testorg.junit.Assert.*不存在.

I am attempting to run JUnit tests in a Scala project in Intellij. Although running the tests through sbt outside Intellij seems to work fine, Intellij seems to be ignoring my added library dependencies -- that is, it's telling me that org.junit.Test and org.junit.Assert.* do not exist.

这是我的build.sbt:

name := "sbt_test"

version := "1.0"

scalaVersion := "2.11.7"

libraryDependencies += "junit" % "junit" % "4.12"
libraryDependencies += "com.novocode" % "junit-interface" % "0.8" % "test->default"

我想念什么?

推荐答案

当Intellij开始行为异常时,通常有助于选择文件">使缓存无效/重新启动".

When Intellij starts misbehaving, it often helps to select File > Invalidate Caches / Restart.

使缓存无效后&重新启动大多数问题似乎消失了.您也可以尝试刷新SBT项目,最后,如果其他所有操作均失败,请删除.idea文件夹,然后重新导入该项目.

After Invalidating Caches & Restarting most issues seem to disappear. You can also try refreshing the SBT Project, and finally, if all else fails delete the .idea folder and reimport the project.

这篇关于Intellij似乎在Scala项目中忽略了我的JUnit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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