IntelliJ 运行/调试配置中的变量
我想在 IntelliJ 中为 JUnit 设置运行/调试配置。我知道如何设置它来运行特定的包
、特定的类
或特定的方法
。我想知道是否有一种方法可以设置配置,以便它将运行当前打开的 Class
文件或当前选择的测试方法
。我想我会把这样的东西放在运行/调试配置
对话框的Class
字段中:
my.package.tests.${currentTest}
或者类似的东西。有没有办法完成此操作,这样我就不必为我想要运行的每个测试类进行运行/调试配置?
I am wanting to set up a Run/Debug Configuration in IntelliJ for JUnit. I know how to set it up to run a specific package
, a specific class
, or a specific method
. I was wondering if there was a way to set up the configurations so it will run the currently opened Class
file or the currently selected test method
. I would imagine I would put something like this in the Class
field of the Run/Debug Configurations
dialog box:
my.package.tests.${currentTest}
or something like that. Is there a way to accomplish this so I don't have to make a Run/Debug Configuration for each test class I want to run?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用右键单击> “run testYourtest()”或在键盘映射中定义为“运行上下文配置”的快捷方式。
通常是 ctrl + shift + F10。
You can either use the right-click > "run testYourtest()" or the shortcut define in the keymap as "Run context configuration".
Usually it's ctrl + shift + F10.
如果您需要对所有测试进行特定设置,您可以更改默认设置,例如 add -ea。这样您就不需要为每个测试进行配置。
顺便说一句:您可以通过首先选择包来运行包中的所有测试。有时最好运行一组测试来检查您是否没有更改一些意外的内容。
If you need specific settings for all you tests you can change the defaults e.g. add -ea. This way you don't need a configuration for each test.
BTW: YoU can run all the tests in a package, by selecting the package first. Sometimes it is better to run a group of tests to check you haven't changed something unintended.