packaging selenium code as jar

Discussion in 'Java' started by Mohan, Feb 8, 2012.

  1. Mohan

    Mohan Guest

    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?
    Mohan, Feb 8, 2012
    #1
    1. Advertising

  2. 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
    Arved Sandstrom, Feb 8, 2012
    #2
    1. Advertising

  3. Mohan

    Mohan Guest

    On Feb 8, 3:42 pm, Arved Sandstrom <>
    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.
    Mohan, Feb 9, 2012
    #3
  4. On 12-02-09 02:03 AM, Mohan wrote:
    > On Feb 8, 3:42 pm, Arved Sandstrom <>
    > 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
    Arved Sandstrom, Feb 10, 2012
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    555
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,689
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,728
    Roedy Green
    Feb 14, 2006
  4. Arnold Peters
    Replies:
    0
    Views:
    639
    Arnold Peters
    Jan 5, 2005
  5. webtester
    Replies:
    0
    Views:
    148
    webtester
    Aug 12, 2008
Loading...

Share This Page