Does KotlinTest also support TestNG?

2019-08-26 00:57发布

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

2条回答
Deceive 欺骗
2楼-- · 2019-08-26 01:10

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();
}

}

查看更多
Fickle 薄情
3楼-- · 2019-08-26 01:15

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

查看更多
登录 后发表回答