I have a problem with testNG, how to create .jar(executeable) from testNG files. im using eclipse Luna.
Thanks
I have a problem with testNG, how to create .jar(executeable) from testNG files. im using eclipse Luna.
Thanks
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 ISuiteListener
and 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.