简体   繁体   English

IntelliJ org.junit.Assert.assertEquals的静态导入完成的奇怪行为

[英]IntelliJ strange behavior of static import completion for org.junit.Assert.assertEquals

In IntelliJ, when I press Alt Enter , it correctly offers to add static import for assertNotEquals : 在IntelliJ中,当我按Alt Enter时 ,它可以正确地为assertNotEquals添加静态导入:

在此处输入图片说明

But not for assertEquals : 但不是assertEquals

在此处输入图片说明

Furthermore, when I press Control Alt Space , it doesn't offer assertEquals , only assertNotEquals and assertArrayEquals : 此外,当我按Control Alt Space时 ,它不提供assertEquals ,仅提供assertNotEqualsassertArrayEquals

在此处输入图片说明

I have to add the static import by typing manually. 我必须通过手动键入来添加静态导入。 Even then, it doesn't help auto-completing, it only offers assertNotEquals and assertArrayEquals while typing. 即使这样,它也无助于自动assertArrayEquals ,它仅在键入时提供assertNotEqualsassertArrayEquals

Oddly, this only happens on my work PC in Windows. 奇怪的是,这仅发生在Windows中的工作PC上。 I had this problem since version 11, 12, 13, now I'm using version 14.3, community edition. 自版本11、12、13开始出现此问题,现在使用的是社区版本14.3。

Why is this happening and how can I make it offer assertEquals ? 为什么会发生这种情况,如何使它提供assertEquals

Side note: I don't know if this is relevant, but it used to offer assertEquals from junit.framework instead of org.junit . 旁注:我不知道这是否相关,但是它曾经从junit.framework而不是org.junit提供assertEquals That was error prone and annoying, so I disabled all imports from junit.framework . 那是容易出错和烦人的,所以我禁用了从junit.framework所有导入。

This can happen if you have excluded org.junit.Assert.assertEquals in the settings. 如果您在设置中排除了org.junit.Assert.assertEquals ,则可能会发生这种情况。 Open your settings and search for "imports". 打开设置并搜索“导入”。 In Editor / General / Auto Import you can configure a list of classes and pacakges to Exclude from Import and Completion . 在“ 编辑器” /“常规” /“自动导入”中,您可以配置要从“导入和完成”中排除的类和功能列表。

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

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