Somewhat related. Is there any way for my team to ...
# intellij
c
Somewhat related. Is there any way for my team to make sure they use the right import? Is there a right import? Can intellij block out the others?
w
You can block imports locally, when IJ suggests an import press alt+enter and you’ll be offered to exclude certain imports from completion
I’m not sure this can be shared in project directory, though
r
iirc, there is project setting somewhere, that does "exclude these packages from imports" or something like that should be helpful exactly for this
here, tho no idea where it's stored, but I assume it should be in IntelliJ's project files... so if you have those in your VCS...
yup, found it stored in
.idea/codeInsightSettings.xml
👍 1
c
Thanks. Anyone here know if there's any "right" junit import? 😄
nope 1
e
junit.framework is JUnit 3
org.junit is JUnit 4
org.junit.jupiter.api is JUnit Jupiter (JUnit 5)
c
So weird that I only have a single dependency on junit 4 and it shows all 3 though
e
are you on Android?
c
Technically this is a java only Gradle module with a single test dependency. Junit 4.12
e
they bundled JUnit 3 with the instrumentation test framework, it's still around but deprecated
ah, might be pulled in transitively too
asserts throw AssertionError regardless, so it's not like super critical…
now that I think of it, JUnit 4 includes a runner for JUnit 3 tests so that might be why
anyhow if you have no Android then your have no reason not to switch to JUnit 5 and drop both 3/4 compatibility :)
c
I've heard that junit 5 isn't all that great which is why I stick to 4.
w
if you have no Android then your have no reason not to switch to JUnit 5
There’s little reason to use JUnit 4 with Android regardless. Robolectric should be avoided anyway, and it pulls its own runner if you need it, UI tests just have own runner as well. For all other unit tests you can use whatever, including JUnit 5
n
btw I'd probably rely on something in your build, e.g. CheckStyle or similar, to enforce not importing things. not everyone uses IntelliJ 100% of the time
c
Good point. We don't use check style but might introduce it is it highlights errors in the IDE
n
ah right, given that this is the Kotlin server...well, ktlint or Detekt probably has something analogous
e
Detekt has a style.ForbidenImport rule, yes
👏 2
m
@Colton Idle I'm going to create a quandary for you and tell you that Jupiter is way better than Junit4. I am honestly saying that. Proper parameterized tests. Clean addition of extensions. Nested tests. Cleaner code as things don't require 'public'. And many more. I suggest you take a look, and judge for yourself.
👍 1
n
the parameterized tests improvements, and better extensions, are what sold me