Skip to main content



      Home
Home » Newcomers » Newcomers » junit and external file
junit and external file [message #257985] Tue, 10 June 2008 11:25 Go to next message
Eclipse UserFriend
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 13:00 Go to previous messageGo to next message
Eclipse UserFriend
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 00:58 Go to previous message
Eclipse UserFriend
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: Fri May 02 22:54:38 EDT 2025

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

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

Back to the top