How to run a single test from TestNG.XML file in command line from Gradle Kotlin

Viewed 232

I have testNG file which has multiple methods. In this testNG file I added the parameters to pass the parameter on code from xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="LocalIosTestSuite" parallel="tests" thread-count="1" >
    <test name="iphonetest">
        <parameter name="platformName" value="iphonetest" />
        <classes>
            <class name="tests.TestKotlin">
            </class>
        </classes>
    </test>
    <test name="androidtest">
        <parameter name="platformName" value="androidtest" />

        <classes>
            <class name="tests.TestKotlin">
            </class>
        </classes>
    </test>
</suite>

Kotlin Class

import org.testng.annotations.Parameters
import org.testng.annotations.Test

class TestKotlin {

    @Parameters("platformName")
    @Test()
    fun Testmethod(platformName:String)
    {
        println("TestKotlin")
        println(platformName)
    }
    
}

Command to run a single test from testng file

 ./gradlew test -Psuite5 -testnames iphonetest

This is not working for me please help me any solution to run a specific test on gradle

0 Answers
Related