Created
August 17, 2022 22:56
-
-
Save Bachmann1234/78896cc10a96e2e6bdb29f73d3885523 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
} | |
open class AbstractTest { | |
} | |
@ExtendWith(BasicParameterResolver::class) | |
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