Created
February 9, 2023 11:46
-
-
Save scottyab/fa76d23d5eb74c65ecbb57423b7a74d1 to your computer and use it in GitHub Desktop.
Jetbrains IDE code template for JUnit tests written in Kotlin.
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
package ${PACKAGE_NAME} | |
import com.nhaarman.mockitokotlin2.verify | |
import com.nhaarman.mockitokotlin2.whenever | |
import org.assertj.core.api.Assertions.assertThat | |
import org.junit.Before | |
import org.junit.Test | |
import org.junit.runner.RunWith | |
import org.mockito.Mock | |
import org.mockito.junit.MockitoJUnitRunner | |
@RunWith(MockitoJUnitRunner::class) | |
class ${NAME}Test { | |
@Mock | |
private lateinit var dependency: Dependency | |
private lateinit var sut: ${NAME}Test | |
@Before | |
fun setUp() { | |
sut = ${NAME}Test(dependency) | |
} | |
@Test | |
fun `foo SHOULD do something WHEN precondition`(){ | |
whenever(dependency.bar()).thenResult("") | |
val expectedResult = "a String" | |
val result = sut.foo() | |
assertThat(result).isEqualTo(expectedResult) | |
verify(dependency).bar() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment