简体   繁体   English

如何使IntelliJ Scala插件运行单元测试,或者如何告诉IntelliJ文件是单元测试代码?

[英]How to make IntelliJ Scala plugin run the unit test, or how to teach IntelliJ that a file is a unit test code?

In IntelliJ/Scala plugin, how can I run the Scala test code? 在IntelliJ / Scala插件中,如何运行Scala测试代码?

class TestFile extends FunSuite with BeforeAndAfter {
  test ("simple") {

I'm not sure exactly what happened, but I remember IntelliJ/Scala plugin automatically showed me a "run" menu with the right click, but I see nothing about the run menu. 我不确定到底发生了什么,但是我记得IntelliJ / Scala插件会通过右键单击自动向我显示“运行”菜单,但是我对运行菜单一无所知。 Is there any setup change to teach this file is Scala test file that can be executed? 是否有任何设置更改来说明此文件是可以执行的Scala测试文件?

在此处输入图片说明

Find the directory where all your tests are (if you are using Maven directory structure that would be src/test/scala) right click on it and choose "Mark directory as"-> "Test Sources Root". 找到所有测试所在的目录(如果使用的是src / test / scala的Maven目录结构),右键单击该目录,然后选择“将目录标记为”->“测试源根目录”。 This would tell IntelliJ that the directory contains test and would make it offer to run tests in the right click menu of files 这将告诉IntelliJ目录包含测试,并使其可以在文件的右键菜单中运行测试。

Right click on the source (especially on test class name or test name) opens up a menu that shows the run menu. 右键单击源(特别是测试类名称或测试名称)会打开一个显示运行菜单的菜单。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM