Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #11898

Re: packaging selenium code as jar

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: packaging selenium code as jar
References <40b6f70a-1be5-41e1-bd03-e6898f3288eb@t30g2000vbx.googlegroups.com> <DksYq.1020$Qb4.575@newsfe21.iad> <60676a24-0efc-45a3-b959-766405c3e73a@i2g2000vbv.googlegroups.com>
Message-ID <mA_Yq.5010$Tu.4341@newsfe05.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2012-02-09 21:40 -0400

Show all headers | View raw


On 12-02-09 02:03 AM, Mohan wrote:
> On Feb 8, 3:42 pm, Arved Sandstrom <asandstrom3min...@eastlink.ca>
> wrote:
>> On 12-02-07 11:00 PM, Mohan wrote:
>>
>>> 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,
> 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
-- 
...wherever the people are well informed they can be trusted with their
own government...
-- Thomas Jefferson, 1789

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

packaging selenium code as jar Mohan <ankurarora81@gmail.com> - 2012-02-07 19:00 -0800
  Re: packaging selenium code as jar Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-02-08 06:42 -0400
    Re: packaging selenium code as jar Mohan <ankurarora81@gmail.com> - 2012-02-08 22:03 -0800
      Re: packaging selenium code as jar Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-02-09 21:40 -0400

csiph-web