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