You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mick Knutson <mi...@gmail.com> on 2008/01/17 19:51:58 UTC

[m2] How do I get ${basedir} information in junit tests?

I want to convert:

          fileString = FileUtils.getStringFromFile(

"C:\\viewstore\\esp_lynx_dap\\esp\\dap\\utilities\\common\\common-jar\\src\\test\\resources\\test.txt");


into something like:

          fileString = FileUtils.getStringFromFile(
                  "${basedir}\\src\\test\\resources\\test.txt");

inside my junit test. Is there a way to do this?

-- 
Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/BLiNCMagazine
http://tahoe.baselogic.com
---

Re: [m2] How do I get ${basedir} information in junit tests?

Posted by Wayne Fay <wa...@gmail.com>.
Realistically, you shouldn't be doing either of those. Instead, you
should use the getResourceAsStream() method of your ClassLoader etc.
Since the file is in the src/test/resources, it will be copied to your
target/test-classes directory and your code can access it directly
from there.

We've talked about this on this list several times, so check the
archive, or post back if you can't find it or its not working.

Wayne

On 1/17/08, Mick Knutson <mi...@gmail.com> wrote:
> I want to convert:
>
>           fileString = FileUtils.getStringFromFile(
>
> "C:\\viewstore\\esp_lynx_dap\\esp\\dap\\utilities\\common\\common-jar\\src\\test\\resources\\test.txt");
>
>
> into something like:
>
>           fileString = FileUtils.getStringFromFile(
>                   "${basedir}\\src\\test\\resources\\test.txt");
>
> inside my junit test. Is there a way to do this?
>
> --
> Thanks,
> Mick Knutson
>
> http://www.baselogic.com
> http://www.blincmagazine.com
> http://www.djmick.com
> http://www.myspace.com/mickknutson
> http://www.myspace.com/BLiNCMagazine
> http://tahoe.baselogic.com
> ---
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org