0

I have a problem with testNG, how to create .jar(executeable) from testNG files. im using eclipse Luna.

Thanks

Syafriadi Hidayat
  • 59
  • 1
  • 4
  • 10
  • 1
    http://stackoverflow.com/questions/16393223/how-to-create-a-executable-jar-file-for-testng-and-the-runnnig-point-should-be-t should help. – Sanjay Bhimani Jan 22 '16 at 09:56
  • 1
    Refer my answer :- http://stackoverflow.com/questions/34489971/how-to-execute-testng-project-without-main-method-from-command-line/34506017#34506017 – Shubham Jain Jan 22 '16 at 11:11

1 Answers1

0

Your question is confusing. But I guess you want to generate jar file using testng where you have set of classes with different functionalities for automation testing.

Create testng class file which imports ITestListener or ISuiteListenerand implement functionality based on requirement.

Generate ant file with different targets where you can compile your code. You have to set target for generate jar in ant xml file.

With this jar file you need to just import and set in other project's build path. Now you can access whole functionalities created in jar.

Below code will be helpful to create executable jar into ant xml file.

<!-- compile-build is previous target. current build is depend on it. After compilation this build executed -->
<!-- directory-attrib is attribule to where you save your jar -->
<!-- bin.dir is you compiled class file, generally it is bin directory -->
<!-- version-num is version num specified by you -->
<property name="bin.dir" value="${basedir}/bin" />
<target name="build" depends="compile-build"
    description="build and pack Jar API classes">
    <jar destfile="${directory-attrib}/ur-jar-name.jar" basedir="${bin.dir}">
        <manifest>
            <attribute name="Built-By" value="${user.name}" />
            <section name="Build-Info">
                <attribute name="Version" value="${version-num}" />
            </section>
        </manifest>
    </jar>
</target>

Generate build xml file and compile as Ant Build.

Sanjay Bhimani
  • 1,593
  • 1
  • 15
  • 29