Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Creating relative path during Junit test run?
Creating relative path during Junit test run? [message #271844] Tue, 30 June 2009 21:10 Go to next message
Eclipse UserFriend
Originally posted by: riwright.adobe.com

I try to be a good citizen and write Junit tests as I go along. Eclipse
helps out a lot there. But one problem I have run into is creating new
files relative to my workspace, ideally in a sub-folder of the Junit test or
similar. Normally I would do something like

Ifile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new
Path("zot.txt"));

This works fine when I am in a running plugin. But when used in a Junit
test I get the message "Workbench closed".

What's the right way to do this? I'll keep poking, but if anyone knows the
right answer, I would be appreciative.

TIA, Ric
Re: Creating relative path during Junit test run? [message #271859 is a reply to message #271844] Wed, 01 July 2009 07:21 Go to previous messageGo to next message
zapping is currently offline zappingFriend
Messages: 8
Registered: July 2009
Junior Member
Hi,
Try System.getProperty("user.dir") this will return the users directory

Cheers
Re: Creating relative path during Junit test run? [message #271935 is a reply to message #271844] Thu, 02 July 2009 17:43 Go to previous message
Eclipse UserFriend
Originally posted by: riwright.adobe.com

Pilot error on my part, in effect. I was launching the JUnit test directly
rather than via the JUnit plugin. Once I did that, I was in business.

Ric


On 6/30/09 2:10 PM, in article C66FCD60.2C214%riwright@adobe.com, "Ric
Wright" <riwright@adobe.com> wrote:

> I try to be a good citizen and write Junit tests as I go along. Eclipse
> helps out a lot there. But one problem I have run into is creating new
> files relative to my workspace, ideally in a sub-folder of the Junit test or
> similar. Normally I would do something like
>
> Ifile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new
> Path("zot.txt"));
>
> This works fine when I am in a running plugin. But when used in a Junit
> test I get the message "Workbench closed".
>
> What's the right way to do this? I'll keep poking, but if anyone knows the
> right answer, I would be appreciative.
>
> TIA, Ric
>
Previous Topic:Hot swapping a file starts a full rebuild
Next Topic:Numpad Enter key in OS X
Goto Forum:
  


Current Time: Sat Sep 14 09:17:38 GMT 2024

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

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

Back to the top