Does KotlinTest also support TestNG?

帅比萌擦擦* 提交于 2019-12-25 00:02:42

问题


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



来源:https://stackoverflow.com/questions/51670665/does-kotlintest-also-support-testng

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!