0

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)

zapl
  • 63,179
  • 10
  • 123
  • 154
  • What is it that you ultimately want to achieve / test? I don't understand why you want to inherit `AuthService`, or for example why you put `@RunWith(Parameterized::class)` on a class that isn't a test itself? You seem to misunderstand that annotation as far as I can tell. – zapl Sep 07 '18 at 11:48
  • Do you maybe want to inherit a second test runner? Doesn't work, only 1 `@RunWith` / runner is supported by JUnit: related https://stackoverflow.com/questions/24431427/multiple-runwith-statements-in-junit – zapl Sep 07 '18 at 12:26

0 Answers0