I have a test class
@RunWith(SpringRunner::class)
@SpringBootTest
@ActiveProfiles("dev")
open class RegisterTest : AuthService() {
@Test
fun negative_login_register_test() {
val requestUser =
createUserWithIncorrectEmail("fsdfs@dfsdfsd..com")
val errorResponseUser: ErrorResponse =
registerIncorrectUser(requestUser)
Assert.assertEquals("User was found in fraud detection system",
errorResponseUser.errorMessage)
Assert.assertEquals("100010", errorResponseUser.errorCode)
}
}
I need to use in this test any dataProviders or their analogues, but my variant doesn't work.
As you see I inherit class AuthService
. This is @Configuration
class and can I use it for store my DataProvider
or Parameterized
class with my companion objects with parameters and use it in my test class? Like:
@Configuration
@RunWith(Parameterized::class) // Or (DataProvider::class)
@ComponentScan(value = "ignore")
@ContextConfiguration(
classes = arrayOf(YAMLConfig::class),
initializers = arrayOf(ConfigFileApplicationContextInitializer::class))
open class AuthService {
companion object {
fun incorrectEmails() = setOf(
"Joe Smith <email@domain.com>",
"email@domain")
}
}
Maybe someone did it? not necessary in kotlin, but combine inheritance and different runners in @Configuration
and @Run
with class.
P.S. I plan to have many tests in one class? and for every @Test
I want use different Dataprovider(or his analogue)