Skip to content

Instantly share code, notes, and snippets.

@Bachmann1234
Created August 17, 2022 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bachmann1234/7f1b38f9c89c6d3852b2209978458f73 to your computer and use it in GitHub Desktop.
Save Bachmann1234/7f1b38f9c89c6d3852b2209978458f73 to your computer and use it in GitHub Desktop.
Triggers false warning in intellij
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.api.extension.ExtensionContext
import org.junit.jupiter.api.extension.ParameterContext
import org.junit.jupiter.api.extension.ParameterResolver
class BasicParameterResolver : ParameterResolver {
override fun supportsParameter(parameterContext: ParameterContext?, extensionContext: ExtensionContext?): Boolean {
return parameterContext != null && parameterContext.parameter.type == ValueBox::class.java
}
override fun resolveParameter(parameterContext: ParameterContext?, extensionContext: ExtensionContext?): Any {
return ValueBox(2)
}
}
class ValueBox constructor(val value: Int) {
}
@ExtendWith(BasicParameterResolver::class)
open class AbstractTest {
}
class TestMain: AbstractTest() {
private lateinit var valueBox : ValueBox;
@BeforeEach
fun beforeEach(valueBox : ValueBox){
this.valueBox = valueBox
}
@Test
fun testWasSetToTwo() {
Assertions.assertEquals(2, valueBox.value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment