Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » junit and external file
junit and external file [message #257985] Tue, 10 June 2008 15:25 Go to next message
No real name is currently offline No real nameFriend
Messages: 64
Registered: July 2009
Member
hi all
I have to make junit test with external file in simple
I have to open a file , read some data , (see if there are correct) etc..;

le prob is how to have the same path even if test move to another pc.
my best solution is put that on the jar itself but what is the reltive
path of the current jar??

thanks

a++
Re: junit and external file [message #258014 is a reply to message #257985] Tue, 10 June 2008 17:00 Go to previous messageGo to next message
Wayne Beaton is currently offline Wayne BeatonFriend
Messages: 554
Registered: December 2017
Senior Member
YOur first and best choice is to include the file in the JAR and use the
Class.getResourceAsStream() method to get it. This, however, doesn't
work so well if you have to write to the file. It does have the benefit
of working anywhere, including a JAR or bundle.

Another option is to explicitly set the working directory in your launch
configuration (on the Arguments tab).

HTH,

Wayne

On Tue, 2008-06-10 at 17:25 +0200, julien wrote:
> hi all
> I have to make junit test with external file in simple
> I have to open a file , read some data , (see if there are correct) etc..;
>
> le prob is how to have the same path even if test move to another pc.
> my best solution is put that on the jar itself but what is the reltive
> path of the current jar??
>
> thanks
>
> a++
Re: junit and external file [message #258083 is a reply to message #258014] Wed, 11 June 2008 04:58 Go to previous message
No real name is currently offline No real nameFriend
Messages: 64
Registered: July 2009
Member
Wayne Beaton a écrit :
> YOur first and best choice is to include the file in the JAR and use the
> Class.getResourceAsStream() method to get it. This, however, doesn't
> work so well if you have to write to the file. It does have the benefit
> of working anywhere, including a JAR or bundle.
>
> Another option is to explicitly set the working directory in your launch
> configuration (on the Arguments tab).
>
> HTH,
>
> Wayne
>
> On Tue, 2008-06-10 at 17:25 +0200, julien wrote:
>> hi all
>> I have to make junit test with external file in simple
>> I have to open a file , read some data , (see if there are correct) etc..;
>>
>> le prob is how to have the same path even if test move to another pc.
>> my best solution is put that on the jar itself but what is the reltive
>> path of the current jar??
>>
>> thanks
>>
>> a++
>
thanks,

I ll look

a++
Previous Topic:why can't I repeat the drawing button in Editor of Eclipse?
Next Topic:Right-click hangs UI
Goto Forum:
  


Current Time: Wed Jul 17 03:35:48 GMT 2024

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

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

Back to the top