I created something: <https://github.com/BraisGabi...
# detekt
b
I created something: https://github.com/BraisGabin/detekt-junit-rules It's a rule set to avoid common mistakes while using JUnit. Right now it just have one rule but it's an important one: did you know that if your
@Test
function doesn't return
Unit
JUnit will not execute it? But, no one returns something in those functions, right? Well... if you uses coroutines and follow this pattern in your tests:
@Test fun foo() = runBlocking { ... }
your tests are not executed at all. Give the custom rule a try if you want 🙂. All feedback is more than welcome.
🎉 7
😮 2
e
does this use/require type resolution? because
Copy code
@Test
fun test() = run {
    assertTrue(true)
}
should be ok
b
Yes, it does. The rule only works with Type resolution. And yes, that code is fine and it's not flagged.
👍 1
m
Playing devils advocate here 😉 This rule in ArchUnit would look like this:
Copy code
@AnalyzeClasses(packages = "<http://com.company.my|com.company.my>")
class ArchUnitTest {

    @ArchTest
    val returnVoidRule = methods()
        .that().areAnnotatedWith(Test.class)
                .should().haveRawReturnType("void");
}
Since junit obviously is used in your case, it would be really simple to set it up.
b
I didn't know ArchUnit. That api looks so cool! It's so easy to read!