diff --git a/testng-core/src/test/java/test/SimpleBaseTest.java b/testng-core/src/test/java/test/SimpleBaseTest.java deleted file mode 100644 index 891f15a37b..0000000000 --- a/testng-core/src/test/java/test/SimpleBaseTest.java +++ /dev/null @@ -1,443 +0,0 @@ -package test; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import org.testng.Assert; -import org.testng.ITestNGMethod; -import org.testng.ITestObjectFactory; -import org.testng.ITestResult; -import org.testng.TestNG; -import org.testng.TestNGException; -import org.testng.annotations.ITestAnnotation; -import org.testng.collections.Lists; -import org.testng.internal.annotations.AnnotationHelper; -import org.testng.internal.annotations.DefaultAnnotationTransformer; -import org.testng.internal.annotations.IAnnotationFinder; -import org.testng.internal.annotations.JDK15AnnotationFinder; -import org.testng.xml.XmlClass; -import org.testng.xml.XmlGroups; -import org.testng.xml.XmlInclude; -import org.testng.xml.XmlPackage; -import org.testng.xml.XmlRun; -import org.testng.xml.XmlSuite; -import org.testng.xml.XmlTest; -import org.testng.xml.internal.Parser; - -public class SimpleBaseTest { - // System property specifying where the resources (e.g. xml files) can be found - private static final String TEST_RESOURCES_DIR = "test.resources.dir"; - - public static InvokedMethodNameListener run(Class... testClasses) { - return run(false, testClasses); - } - - public static InvokedMethodNameListener run(boolean skipConfiguration, Class... testClasses) { - TestNG tng = create(testClasses); - - return run(skipConfiguration, tng); - } - - public static InvokedMethodNameListener run(XmlSuite... suites) { - return run(false, suites); - } - - public static InvokedMethodNameListener run(boolean skipConfiguration, XmlSuite... suites) { - TestNG tng = create(suites); - - return run(skipConfiguration, tng); - } - - private static InvokedMethodNameListener run(boolean skipConfiguration, TestNG tng) { - InvokedMethodNameListener listener = new InvokedMethodNameListener(skipConfiguration); - tng.addListener(listener); - - tng.run(); - - return listener; - } - - public static TestNG create() { - TestNG result = new TestNG(); - result.setUseDefaultListeners(false); - return result; - } - - public static TestNG create(Class... testClasses) { - TestNG result = create(); - result.setTestClasses(testClasses); - return result; - } - - protected static TestNG create(Path outputDir, Class... testClasses) { - TestNG result = create(testClasses); - result.setOutputDirectory(outputDir.toAbsolutePath().toString()); - return result; - } - - protected static TestNG create(XmlSuite... suites) { - return create(Arrays.asList(suites)); - } - - protected static TestNG create(List suites) { - TestNG result = create(); - result.setXmlSuites(suites); - return result; - } - - protected static TestNG create(Path outputDir, XmlSuite... suites) { - return create(outputDir, Arrays.asList(suites)); - } - - protected static TestNG create(Path outputDir, List suites) { - TestNG result = create(suites); - result.setOutputDirectory(outputDir.toAbsolutePath().toString()); - return result; - } - - protected static TestNG createTests(String suiteName, Class... testClasses) { - return createTests(null, suiteName, testClasses); - } - - protected static TestNG createTests(Path outDir, String suiteName, Class... testClasses) { - XmlSuite suite = createXmlSuite(suiteName); - int i = 0; - for (Class testClass : testClasses) { - createXmlTest(suite, testClass.getName() + i, testClass); - i++; - } - if (outDir == null) { - return create(suite); - } - return create(outDir, suite); - } - - protected static XmlSuite createDummySuiteWithTestNamesAs(String... tests) { - XmlSuite suite = new XmlSuite(); - suite.setName("random_suite"); - for (String test : tests) { - XmlTest xmlTest = new XmlTest(suite); - xmlTest.setName(test); - } - return suite; - } - - protected static XmlSuite createXmlSuite(String name) { - XmlSuite result = new XmlSuite(); - result.setName(name); - return result; - } - - protected static XmlSuite createXmlSuite(Map params) { - XmlSuite result = createXmlSuite(UUID.randomUUID().toString()); - result.setParameters(params); - return result; - } - - protected static XmlSuite createXmlSuite(String suiteName, String testName, Class... classes) { - XmlSuite suite = createXmlSuite(suiteName); - createXmlTest(suite, testName, classes); - return suite; - } - - protected static XmlSuite createXmlSuite(String suiteName, Map params) { - XmlSuite suite = createXmlSuite(suiteName); - suite.setParameters(params); - return suite; - } - - protected static XmlTest createXmlTestWithPackages( - XmlSuite suite, String name, String... packageName) { - XmlTest result = createXmlTest(suite, name); - List xmlPackages = Lists.newArrayList(); - - for (String each : packageName) { - XmlPackage xmlPackage = new XmlPackage(); - xmlPackage.setName(each); - xmlPackages.add(xmlPackage); - } - result.setPackages(xmlPackages); - - return result; - } - - protected static XmlTest createXmlTestWithPackages( - XmlSuite suite, String name, Class... packageName) { - XmlTest result = createXmlTest(suite, name); - List xmlPackages = Lists.newArrayList(); - - for (Class each : packageName) { - XmlPackage xmlPackage = new XmlPackage(); - xmlPackage.setName(each.getPackage().getName()); - xmlPackages.add(xmlPackage); - } - result.setPackages(xmlPackages); - - return result; - } - - protected static XmlTest createXmlTest(String suiteName, String testName) { - XmlSuite suite = createXmlSuite(suiteName); - return createXmlTest(suite, testName); - } - - protected static XmlTest createXmlTest(String suiteName, String testName, Class... classes) { - XmlSuite suite = createXmlSuite(suiteName); - XmlTest xmlTest = createXmlTest(suite, testName); - for (Class clazz : classes) { - xmlTest.getXmlClasses().add(new XmlClass(clazz)); - } - return xmlTest; - } - - protected static XmlTest createXmlTest(XmlSuite suite, String name) { - XmlTest result = new XmlTest(suite); - result.setName(name); - return result; - } - - protected static XmlTest createXmlTest(XmlSuite suite, String name, Map params) { - XmlTest result = new XmlTest(suite); - result.setName(name); - result.setParameters(params); - return result; - } - - protected static XmlTest createXmlTest(XmlSuite suite, String name, Class... classes) { - XmlTest result = createXmlTest(suite, name); - int index = 0; - for (Class c : classes) { - XmlClass xc = new XmlClass(c.getName(), index++, true /* load classes */); - result.getXmlClasses().add(xc); - } - - return result; - } - - protected static XmlClass createXmlClass(XmlTest test, Class testClass) { - XmlClass clazz = new XmlClass(testClass); - test.getXmlClasses().add(clazz); - return clazz; - } - - protected static XmlClass createXmlClass( - XmlTest test, Class testClass, Map params) { - XmlClass clazz = createXmlClass(test, testClass); - clazz.setParameters(params); - return clazz; - } - - protected static XmlInclude createXmlInclude(XmlClass clazz, String method) { - XmlInclude include = new XmlInclude(method); - - include.setXmlClass(clazz); - clazz.getIncludedMethods().add(include); - - return include; - } - - protected static XmlInclude createXmlInclude( - XmlClass clazz, String method, Map params) { - XmlInclude include = createXmlInclude(clazz, method); - include.setParameters(params); - return include; - } - - protected static XmlInclude createXmlInclude( - XmlClass clazz, String method, int index, Integer... list) { - XmlInclude include = new XmlInclude(method, Arrays.asList(list), index); - - include.setXmlClass(clazz); - clazz.getIncludedMethods().add(include); - - return include; - } - - protected static XmlGroups createXmlGroups(XmlSuite suite, String... includedGroupNames) { - XmlGroups xmlGroups = createGroupIncluding(includedGroupNames); - suite.setGroups(xmlGroups); - return xmlGroups; - } - - protected static XmlGroups createXmlGroups(XmlTest test, String... includedGroupNames) { - XmlGroups xmlGroups = createGroupIncluding(includedGroupNames); - test.setGroups(xmlGroups); - return xmlGroups; - } - - private static XmlGroups createGroupIncluding(String... groupNames) { - XmlGroups xmlGroups = new XmlGroups(); - XmlRun xmlRun = new XmlRun(); - for (String group : groupNames) { - xmlRun.onInclude(group); - } - xmlGroups.setRun(xmlRun); - return xmlGroups; - } - - protected static XmlTest createXmlTest(XmlSuite suite, String name, String... classes) { - XmlTest result = createXmlTest(suite, name); - int index = 0; - for (String c : classes) { - XmlClass xc = new XmlClass(c, index++, true /* load classes */); - result.getXmlClasses().add(xc); - } - - return result; - } - - protected static void addMethods(XmlClass cls, String... methods) { - int index = 0; - for (String method : methods) { - XmlInclude include = new XmlInclude(method, index++); - cls.getIncludedMethods().add(include); - } - } - - public static String getPathToResource(String fileName) { - String result = System.getProperty(TEST_RESOURCES_DIR, "src/test/resources"); - if (result == null) { - throw new IllegalArgumentException( - "System property " + TEST_RESOURCES_DIR + " was not defined."); - } - return result + File.separatorChar + fileName; - } - - public static List extractTestNGMethods(Class... classes) { - XmlSuite xmlSuite = new XmlSuite(); - xmlSuite.setName("suite"); - XmlTest xmlTest = createXmlTest(xmlSuite, "tests", classes); - IAnnotationFinder annotationFinder = - new JDK15AnnotationFinder(new DefaultAnnotationTransformer()); - List methods = Lists.newArrayList(); - for (Class clazz : classes) { - methods.addAll( - Arrays.asList( - AnnotationHelper.findMethodsWithAnnotation( - new ITestObjectFactory() {}, - clazz, - ITestAnnotation.class, - annotationFinder, - xmlTest))); - } - return methods; - } - - /** Compare a list of ITestResult with a list of String method names, */ - protected static void assertTestResultsEqual(List results, List methods) { - List resultMethods = Lists.newArrayList(); - for (ITestResult r : results) { - resultMethods.add(r.getMethod().getMethodName()); - } - Assert.assertEquals(resultMethods, methods); - } - - /** Deletes all files and subdirectories under dir. */ - protected static void deleteDir(File dir) { - try { - Files.walkFileTree( - dir.toPath(), - new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) - throws IOException { - Files.delete(file); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) - throws IOException { - Files.delete(dir); - return FileVisitResult.CONTINUE; - } - }); - } catch (IOException e) { - e.printStackTrace(); - } - } - - protected static File createDirInTempDir(String dir) { - File slashTmpDir = new File(System.getProperty("java.io.tmpdir")); - File mTempDirectory = new File(slashTmpDir, dir); - mTempDirectory.mkdirs(); - mTempDirectory.deleteOnExit(); - return mTempDirectory; - } - - /** - * @param fileName The filename to parse - * @param regexp The regular expression - * @param resultLines An out parameter that will contain all the lines that matched the regexp - * @return A List containing the lines of all the matches - *

Note that the size() of the returned valuewill always be equal to result.size() at the - * end of this function. - */ - protected static List grep(File fileName, String regexp, List resultLines) { - List resultLineNumbers = new ArrayList<>(); - try (Reader reader = new FileReader(fileName)) { - resultLineNumbers = grep(reader, regexp, resultLines); - } catch (IOException e) { - e.printStackTrace(); - } - return resultLineNumbers; - } - - protected static List grep(Reader reader, String regexp, List resultLines) { - List resultLineNumbers = new ArrayList<>(); - try (BufferedReader fr = new BufferedReader(reader)) { - String line; - int currentLine = 0; - Pattern p = Pattern.compile(".*" + regexp + ".*"); - while ((line = fr.readLine()) != null) { - if (p.matcher(line).matches()) { - resultLines.add(line); - resultLineNumbers.add(currentLine); - } - currentLine++; - } - } catch (IOException e) { - e.printStackTrace(); - } - return resultLineNumbers; - } - - protected static List getSuites(String... suiteFiles) { - List suites = new ArrayList<>(); - for (String suiteFile : suiteFiles) { - try { - suites.addAll(new Parser(suiteFile).parseToList()); - } catch (IOException e) { - throw new TestNGException(e); - } - } - return suites; - } - - protected static String getFailedResultMessage(List testResultList) { - String methods = - testResultList.stream() - .map( - r -> - new AbstractMap.SimpleEntry<>( - r.getMethod().getQualifiedName(), r.getThrowable())) - .map(e -> String.format("%s: %s", e.getKey(), e.getValue())) - .collect(Collectors.joining("\n")); - return String.format("Failed methods should pass:\n %s\n", methods); - } -} diff --git a/testng-core/src/test/kotlin/test/SimpleBaseTest.kt b/testng-core/src/test/kotlin/test/SimpleBaseTest.kt new file mode 100644 index 0000000000..3c63cdc919 --- /dev/null +++ b/testng-core/src/test/kotlin/test/SimpleBaseTest.kt @@ -0,0 +1,436 @@ +package test + +import org.assertj.core.api.Assertions.assertThat +import org.testng.* +import org.testng.annotations.ITestAnnotation +import org.testng.internal.annotations.AnnotationHelper +import org.testng.internal.annotations.DefaultAnnotationTransformer +import org.testng.internal.annotations.IAnnotationFinder +import org.testng.internal.annotations.JDK15AnnotationFinder +import org.testng.xml.* +import org.testng.xml.internal.Parser +import java.io.* +import java.nio.file.FileVisitResult +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.SimpleFileVisitor +import java.nio.file.attribute.BasicFileAttributes +import java.util.* +import java.util.concurrent.atomic.AtomicInteger +import java.util.regex.Pattern +import java.util.stream.Collectors + +open class SimpleBaseTest { + + companion object { + private const val TEST_RESOURCES_DIR = "test.resources.dir" + + @JvmStatic + fun run(vararg testClasses: Class<*>) = run(false, *testClasses) + + @JvmStatic + private fun run(skipConfiguration: Boolean, tng: TestNG) = + InvokedMethodNameListener(skipConfiguration).apply { + tng.addListener(this) + tng.run() + return this + } + + @JvmStatic + fun run(skipConfiguration: Boolean, vararg testClasses: Class<*>) = + run(skipConfiguration, create(*testClasses)) + + @JvmStatic + fun create(vararg testClasses: Class<*>) = create().apply { + setTestClasses(testClasses) + return this + } + + @JvmStatic + fun create() = TestNG().apply { + setUseDefaultListeners(false) + return this + } + + @JvmStatic + fun create(xmlSuite: XmlSuite) = create().apply { + setXmlSuites(listOf(xmlSuite)) + return this + } + + @JvmStatic + fun run(vararg suites: XmlSuite): InvokedMethodNameListener = run(false, *suites) + + @JvmStatic + fun run(skipConfiguration: Boolean, vararg suites: XmlSuite) = + run(skipConfiguration, create(*suites)) + + @JvmStatic + protected fun create(outputDir: Path, vararg testClasses: Class<*>) = + create(*testClasses).apply { + outputDirectory = outputDir.toAbsolutePath().toString() + return this + } + + @JvmStatic + protected fun create(vararg suites: XmlSuite) = create(listOf(*suites)) + + @JvmStatic + protected fun create(suites: List) = create().apply { + this.setXmlSuites(suites) + return this + } + + @JvmStatic + protected fun create(outputDir: Path, vararg suites: XmlSuite) = + create(outputDir, listOf(*suites)) + + @JvmStatic + protected fun create(outputDir: Path, suites: List) = create(suites).apply { + outputDirectory = outputDir.toAbsolutePath().toString() + return this + } + + @JvmStatic + protected fun createTests(suiteName: String, vararg testClasses: Class<*>) = + createTests(null, suiteName, *testClasses) + + @JvmStatic + protected fun createTests( + outDir: Path?, + suiteName: String, + vararg testClasses: Class<*> + ) = createXmlSuite(suiteName).let { suite -> + + for ((i, testClass) in testClasses.withIndex()) { + createXmlTest(suite, testClass.name + i, testClass) + } + //if outDir is not null then create suite with outDir, else create suite without it. + outDir?.let { create(it, suite) } ?: create(suite) + } + + @JvmStatic + protected fun createDummySuiteWithTestNamesAs(vararg tests: String) = + XmlSuite().apply { + name = "random_suite" + tests.forEach { + XmlTest(this).apply { + name = it + } + } + return this + } + + @JvmStatic + protected fun createXmlSuite(name: String) = XmlSuite().apply { + this.name = name + return this + } + + @JvmStatic + protected fun createXmlSuite(params: Map) = + createXmlSuite(UUID.randomUUID().toString()).apply { + parameters = params + return this + } + + @JvmStatic + protected fun createXmlSuite( + suiteName: String, + testName: String, + vararg classes: Class<*> + ) = createXmlSuite(suiteName).apply { + createXmlTest(this, testName, *classes) + return this + } + + @JvmStatic + protected fun createXmlSuite(suiteName: String, params: Map) = + createXmlSuite(suiteName).apply { + parameters = params + return this + } + + @JvmStatic + protected fun createXmlTestWithPackages( + suite: XmlSuite, name: String, vararg packageName: String + ) = createXmlTest(suite, name).apply { + this.packages = packageName.map { + XmlPackage().apply { + this.name = it + } + }.toMutableList() + return this + } + + @JvmStatic + protected fun createXmlTestWithPackages( + suite: XmlSuite, name: String, vararg packageName: Class<*> + ) = createXmlTest(suite, name).apply { + packages = packageName.map { + XmlPackage().apply { + this.name = it.`package`.name + } + }.toMutableList() + return this + } + + @JvmStatic + protected fun createXmlTest(suiteName: String, testName: String) = + createXmlTest(createXmlSuite(suiteName), testName) + + @JvmStatic + protected fun createXmlTest( + suiteName: String, + testName: String, + vararg classes: Class<*> + ) = createXmlTest(createXmlSuite(suiteName), testName).apply { + classes.forEach { + xmlClasses.add(XmlClass(it)) + } + return this + } + + @JvmStatic + protected fun createXmlTest(suite: XmlSuite, name: String) = XmlTest(suite).apply { + this.name = name + return this + } + + @JvmStatic + protected fun createXmlTest( + suite: XmlSuite, + name: String, + params: Map + ) = XmlTest(suite).apply { + this.name = name + setParameters(params) + return this + } + + @JvmStatic + protected fun createXmlTest( + suite: XmlSuite, + name: String, + vararg classes: Class<*> + ) = createXmlTest(suite, name).apply { + for ((index, c) in classes.withIndex()) { + val xc = XmlClass(c.name, index, true /* load classes */) + xmlClasses.add(xc) + } + return this + } + + @JvmStatic + protected fun createXmlClass(test: XmlTest, testClass: Class<*>) = + XmlClass(testClass).apply { + test.xmlClasses.add(this) + return this + } + + @JvmStatic + protected fun createXmlClass( + test: XmlTest, testClass: Class<*>, params: Map + ) = createXmlClass(test, testClass).apply { + setParameters(params) + return this + } + + @JvmStatic + protected fun createXmlInclude(clazz: XmlClass, method: String) = XmlInclude(method).apply { + setXmlClass(clazz) + clazz.includedMethods.add(this) + return this + } + + @JvmStatic + protected fun createXmlInclude( + clazz: XmlClass, method: String, params: Map + ) = createXmlInclude(clazz, method).apply { + setParameters(params) + return this + } + + @JvmStatic + protected fun createXmlInclude( + clazz: XmlClass, + method: String, + index: Int, vararg list: Int + ) = XmlInclude(method, list.asList(), index).apply { + setXmlClass(clazz) + clazz.includedMethods.add(this) + return this + } + + @JvmStatic + protected fun createXmlGroups( + suite: XmlSuite, + vararg includedGroupNames: String + ) = createGroupIncluding(*includedGroupNames).apply { + suite.groups = this + return this + } + + @JvmStatic + protected fun createXmlGroups( + test: XmlTest, + vararg includedGroupNames: String + ) = createGroupIncluding(*includedGroupNames).apply { + test.setGroups(this) + return this + } + + @JvmStatic + private fun createGroupIncluding(vararg groupNames: String) = XmlGroups().apply { + run = XmlRun().apply { + groupNames.forEach { onInclude(it) } + } + } + + @JvmStatic + protected fun createXmlTest( + suite: XmlSuite, + name: String, + vararg classes: String + ) = createXmlTest(suite, name).apply { + for ((index, c) in classes.withIndex()) { + val xc = XmlClass(c, index, true /* load classes */) + xmlClasses.add(xc) + } + return this + } + + @JvmStatic + protected fun addMethods(cls: XmlClass, vararg methods: String) { + for ((index, method) in methods.withIndex()) { + val include = XmlInclude(method, index) + cls.includedMethods.add(include) + } + } + + @JvmStatic + fun getPathToResource(fileName: String): String { + val result = System.getProperty(TEST_RESOURCES_DIR, "src/test/resources") + ?: throw IllegalArgumentException( + "System property $TEST_RESOURCES_DIR was not defined." + ) + return result + File.separatorChar + fileName + } + + @JvmStatic + fun extractTestNGMethods(vararg classes: Class<*>): List = + XmlSuite().let { xmlSuite -> + xmlSuite.name = "suite" + val xmlTest = createXmlTest(xmlSuite, "tests", *classes) + val annotationFinder: IAnnotationFinder = + JDK15AnnotationFinder(DefaultAnnotationTransformer()) + classes.flatMap { clazz -> + AnnotationHelper.findMethodsWithAnnotation( + object : ITestObjectFactory {}, + clazz, + ITestAnnotation::class.java, + annotationFinder, + xmlTest + ).toMutableList() + } + } + + /** Compare a list of ITestResult with a list of String method names, */ + @JvmStatic + protected fun assertTestResultsEqual(results: List, methods: List) { + results.map { it.method.methodName } + .toList() + .run { + assertThat(this).containsAll(methods) + } + } + + /** Deletes all files and subdirectories under dir. */ + @JvmStatic + protected fun deleteDir(dir: File): Path = + Files.walkFileTree(dir.toPath(), TestNGFileVisitor()) + + @JvmStatic + protected fun createDirInTempDir(dir: String): File = + Files.createTempDirectory(dir) + .toFile().apply { + deleteOnExit() + return this + } + + /** + * @param fileName The filename to parse + * @param regexp The regular expression + * @param resultLines An out parameter that will contain all the lines that matched the regexp + * @return A List containing the lines of all the matches + * + * Note that the size() of the returned valuewill always be equal to result.size() at the + * end of this function. + */ + @JvmStatic + protected fun grep( + fileName: File, + regexp: String, + resultLines: MutableList + ) = grep(FileReader(fileName), regexp, resultLines) + + @JvmStatic + protected fun grep( + reader: Reader, + regexp: String, + resultLines: MutableList + ): List { + val resultLineNumbers = mutableListOf() + val p = Pattern.compile(".*$regexp.*") + val counter = AtomicInteger(-1) + BufferedReader(reader).lines() + .peek { counter.getAndIncrement() } + .filter { line -> p.matcher(line).matches() } + .forEach { + resultLines.add(it) + resultLineNumbers.add(counter.get()) + } + return resultLineNumbers + } + + @JvmStatic + protected fun getSuites(vararg suiteFiles: String) = suiteFiles.map { Parser(it) } + .flatMap { it.parseToList() } + .toList() + + @JvmStatic + protected fun getFailedResultMessage(testResultList: List): String { + val methods = testResultList.stream() + .map { r: ITestResult -> + AbstractMap.SimpleEntry( + r.method.qualifiedName, r.throwable + ) + } + .map { (key, value): AbstractMap.SimpleEntry -> + "$key: $value" + } + .collect(Collectors.joining("\n")) + return "Failed methods should pass: \n $methods" + } + } + + class TestNGFileVisitor : SimpleFileVisitor() { + @Throws(IOException::class) + override fun visitFile( + file: Path, + attrs: BasicFileAttributes + ): FileVisitResult { + Files.delete(file) + return FileVisitResult.CONTINUE + } + + @Throws(IOException::class) + override fun postVisitDirectory( + dir: Path, + exc: IOException? + ): FileVisitResult { + Files.delete(dir) + return FileVisitResult.CONTINUE + } + } +} diff --git a/testng-core/testng-core-build.gradle.kts b/testng-core/testng-core-build.gradle.kts index 046363a023..dfec4a600c 100644 --- a/testng-core/testng-core-build.gradle.kts +++ b/testng-core/testng-core-build.gradle.kts @@ -49,6 +49,14 @@ dependencies { testImplementation("commons-io:commons-io:_") } +tasks.compileTestGroovy { + dependsOn(tasks.compileTestKotlin) + classpath += files(tasks.compileTestKotlin) +} +tasks.compileTestKotlin { + classpath = sourceSets.test.get().compileClasspath +} + tasks.test { maxParallelForks = Runtime.getRuntime().availableProcessors().div(2) (testFramework.options as TestNGOptions).apply {