Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > packaging selenium code as jar

Reply
Thread Tools

packaging selenium code as jar

 
 
Mohan
Guest
Posts: n/a
 
      02-08-2012
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?
 
Reply With Quote
 
 
 
 
Arved Sandstrom
Guest
Posts: n/a
 
      02-08-2012
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
--
....wherever the people are well informed they can be trusted with their
own government...
-- Thomas Jefferson, 1789
 
Reply With Quote
 
 
 
 
Mohan
Guest
Posts: n/a
 
      02-09-2012
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
> --
> ...wherever the people are well informed they can be trusted with their
> own government...
> -- Thomas Jefferson, 1789


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.
 
Reply With Quote
 
Arved Sandstrom
Guest
Posts: n/a
 
      02-10-2012
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selenium and Selenium RC training in London webtester Ruby 0 08-12-2008 02:29 PM
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57