0

I am new to TestNG and Selenium. I am trying to write test cases using Eclipse IDE.

Following is a sample test case which I am using :

package JenkinsPackage;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class JenkinsClass {

    @Test
    public void jenkinsfunction(){

        System.out.println("Hello");
        System.setProperty("webdriver.gecko.driver","D:\\software\\geckodriver-v0.14.0-win64\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("http://my.domain.com");
        System.out.println(driver.getTitle());
        driver.quit();
}

}

When I run the above code it is working perfectly. I have the following questions.

  • How to create a runnable jar of this project , which will run xml file
  • I want to deploy this jar to Jenkins, how to do this ? Since I am not able to create a runnable jar
  • If you are going to be using Jenkins, then you don't need to create a runnable jar. You can merely create a job in your Jenkins instance, which basically pulls code from a version control system (such as SVN or Git), and then runs the code via your build tool (Maven/Ant/Gradle). Why do you want to create a runnable jar ? Can you please elaborate ? – Krishnan Mahadevan Oct 30 '17 at 16:40
  • This might help you https://stackoverflow.com/questions/16782414/how-to-run-testng-tests-on-jenkins – HaC Oct 30 '17 at 19:25
  • I was trying to create jar file in TestNG, but as we know TestNG doesn't have main function so was not able to create Runnable JAR. Now I found solution onhttps://stackoverflow.com/questions/16393223/how-to-create-a-executable-jar-file-for-testng-and-the-runnnig-point-should-be-t This helped me create Runnable JAR using TestNG. – Kaustubh Oct 31 '17 at 06:50

1 Answers1

0

I think you should run using command and intregrate you can call this command via jenkins: java -cp %CLASSPATH% org.testng.TestNG -d ../output ./testng.xml