Does KotlinTest also support TestNG?

2019-08-26 00:22发布

问题:

Can I use KotlinTest with TestNG? I can see only JUnit in the documentation.

回答1:

Yes, you can use TestNG with Kotlin. Just configure TestNG dependency and you are good to go. It is similar to Junit. Below is a sample program for the same:

abstract class TestBase {

lateinit var driver: WebDriver
    private set

@BeforeTest
fun setup() {
    System.setProperty(UtilResources.getProperties("nameDriver"),
            UtilResources.getProperties("pathDriver") + UtilResources.getProperties("exeDriver"))
    driver = ChromeDriver()
    driver?.manage()?.timeouts()?.implicitlyWait(10, TimeUnit.SECONDS)
    driver?.manage()?.window()?.maximize()
    driver?.get(URI(UtilResources.getProperties("pageURL")).toString())
}

@AfterTest
fun driverClose() {
    driver?.close();
}

}



回答2:

The answer is no. KotlinTest is built on JUnit Platform, which is a basis to allow testing libraries to integrate with things like IntelliJ and gradle, without having to themselves write plugins.

As JUnit say themselves,

The JUnit Platform serves as a foundation for launching testing frameworks on the JVM