Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Exclude junit test from runnable jar
Exclude junit test from runnable jar [message #1722128] Tue, 02 February 2016 21:17 Go to next message
Peter Ream is currently offline Peter ReamFriend
Messages: 3
Registered: February 2016
Junior Member
This has been beaten to death, but I still can't make it work. I have read and re-read this thread from sometime ago. It makes sense, but I can't get it to work. I am an eclipse and java noob. I think I have my setup correct. I have all my testing classes in a test source folder. If I export as "jar file", I have the opportunity to exclude my junit tests. However to export as "runnable jar file" I am no longer afforded this exclusion. When I export, I get "JAR export finished with warnings. See details for additional information.
Exported with compile warnings: DigitToWords/test/org/digitstowords/DigitsToWordsTest.java." I have tried setting up my own runnable manifest to no avail. This can't be this difficult or I am an idiot.
Re: Exclude junit test from runnable jar [message #1722133 is a reply to message #1722128] Tue, 02 February 2016 22:53 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3799
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 02/02/2016 03:04 PM, Peter Ream wrote:
> This has been beaten to death, but I still can't make it work. I have
> read and re-read https://www.eclipse.org/forums/index.php/t/198085/ from
> sometime ago. It makes sense, but I can't get it to work. I am an
> eclipse and java noob. I think I have my setup correct. I have all my
> testing classes in a test source folder. If I export as "jar file", I
> have the opportunity to exclude my junit tests. However to export as
> "runnable jar file" I am no longer afforded this exclusion. When I
> export, I get "JAR export finished with warnings. See details for
> additional information.
> Exported with compile warnings:
> DigitToWords/test/org/digitstowords/DigitsToWordsTest.java." I have
> tried setting up my own runnable manifest to no avail. This can't be
> this difficult or I am an idiot.

Not really an Eclipse question here, but does it help if I say this?

To run from the command line a JUnit test you've created, you need a
main() method to call it in your runnable JAR, which you create just as
you would any other runnable JAR.

Create your JUnit test class as normal, here, FunTest, create another
class with a public static void main( String[] args ) inside that calls
it thus:

import junit.textui.TestRunner;

public class RunnableFunTest
{
public static void main( String[] args )
{
TestRunner.run( FunTest.class );
}
}

Obviously, when you run this from the command line, you'll also have to
make allowances for the JUnit JAR (library) to be present whether you
bundled it as a stand-alone or have junit.jar on your classpath.
Re: Exclude junit test from runnable jar [message #1722240 is a reply to message #1722133] Wed, 03 February 2016 15:12 Go to previous message
Peter Ream is currently offline Peter ReamFriend
Messages: 3
Registered: February 2016
Junior Member
I apologize if I am incorrect, but I believe this is an eclipse question. In eclipse, you can export "jar file" which allows for the exclusion of your test classes or "runnable jar file" which does not allow for exclusion.
Previous Topic:Where to report website/documentation errors?
Next Topic:out of memory error
Goto Forum:
  


Current Time: Wed Jun 26 14:05:14 GMT 2019

Powered by FUDForum. Page generated in 0.03654 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top