https://kotlinlang.org logo
c

Colton Idle

04/21/2021, 10:10 AM
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

wasyl

04/21/2021, 10:25 AM
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

Roukanken

04/21/2021, 11:18 AM
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

Colton Idle

04/21/2021, 11:25 AM
Thanks. Anyone here know if there's any "right" junit import? 😄
nope 1
e

ephemient

04/21/2021, 2:42 PM
junit.framework is JUnit 3
org.junit is JUnit 4
org.junit.jupiter.api is JUnit Jupiter (JUnit 5)
c

Colton Idle

04/21/2021, 2:44 PM
So weird that I only have a single dependency on junit 4 and it shows all 3 though
e

ephemient

04/21/2021, 2:44 PM
are you on Android?
c

Colton Idle

04/21/2021, 2:44 PM
Technically this is a java only Gradle module with a single test dependency. Junit 4.12
e

ephemient

04/21/2021, 2:45 PM
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

Colton Idle

04/21/2021, 2:49 PM
I've heard that junit 5 isn't all that great which is why I stick to 4.
w

wasyl

04/21/2021, 3:03 PM
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

nanodeath

04/21/2021, 3:22 PM
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

Colton Idle

04/21/2021, 3:24 PM
Good point. We don't use check style but might introduce it is it highlights errors in the IDE
n

nanodeath

04/21/2021, 3:29 PM
ah right, given that this is the Kotlin server...well, ktlint or Detekt probably has something analogous
e

ephemient

04/21/2021, 3:49 PM
Detekt has a style.ForbidenImport rule, yes
👏 2
m

Mike

04/22/2021, 11:42 AM
@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

nanodeath

04/22/2021, 4:17 PM
the parameterized tests improvements, and better extensions, are what sold me
2 Views