packaging selenium code as jar

M

Mohan

I need to package my selenium script (exported as JUnit4 test) as jar
file to be used by some third party application.
Is such a thing supported? If yes, how can this be done and how would
the manifest file look like?
 
A

Arved Sandstrom

I need to package my selenium script (exported as JUnit4 test) as jar
file to be used by some third party application.
Is such a thing supported? If yes, how can this be done and how would
the manifest file look like?

The JUnit 4 test with code that also uses the Selenium API is simply a
Java class like any other, so of course packaging it as a JAR is supported.

As to whether you need to edit the MANIFEST.MF, that depends on how you
think people will use the test class. How technical are they? Will they
have their own copies of the JUnit and Selenium JARs or are you
providing those also? What environment do you expect the users to run
the test(s) in?

Me, I'd probably package up the test class(es) along with the JAR
dependencies in a ZIP, and include batch and shell scripts to run the
entire business, and not muck around with the manifest file at all.

AHS
 
M

Mohan

The JUnit 4 test with code that also uses the Selenium API is simply a
Java class like any other, so of course packaging it as a JAR is supported.

As to whether you need to edit the MANIFEST.MF, that depends on how you
think people will use the test class. How technical are they? Will they
have their own copies of the JUnit and Selenium JARs or are you
providing those also? What environment do you expect the users to run
the test(s) in?

Me, I'd probably package up the test class(es) along with the JAR
dependencies in a ZIP, and include batch and shell scripts to run the
entire business, and not muck around with the manifest file at all.

AHS

AHS,
I figured what you are trying to say and would want to package all the
stuff inside the jar.
I tried to do that using Eclipse export (File>export) but the 'Launch
Configuration' drop-down list of 'Runnable JAR File Specification'
dialog box is empty.
Did I miss something?
Thanks.
 
A

Arved Sandstrom

AHS,
I figured what you are trying to say and would want to package all the
stuff inside the jar.
I tried to do that using Eclipse export (File>export) but the 'Launch
Configuration' drop-down list of 'Runnable JAR File Specification'
dialog box is empty.
Did I miss something?
Thanks.

You've got several issues here. I use Eclipse a lot but not so much with
exporting runnable JARs. I do know this, if you try to export your
project as a Runnable JAR then you need a "Java Application" launch
configuration.

There are JUnit launch configurations also available, and these can be
quite useful when running tests otherwise (so you don't have to specify
launch parameters over and over again, basically). But in order to run
JUnit tests you need a main class to do it with, for the executable JAR.

One easy way to do it is, set up a JUnit test suite. Add a main() method
to the test suite class that uses JUnitCore.main() or
JUnitCore.runClasses(). Once you've got this, set that test suite class
up as the Main class in a "Java Application" launch configuration. And
once you've got that, it's available in your Runnable JAR launch
configuration dropdown.

As an aside, I like the Runnable JAR export option of copying the
required libraries (in this case that would include JUnit and Hamcrest,
plus any JARS that your real code uses) into a sub-folder next to the
generated JAR. For distribution you can then simply ZIP that library
folder and the generated executable JAR, plus any run scripts and READMEs.

AHS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top