java - JUnit + Maven: accessing ${project.build.directory} value -
in unit tests want create tmp directory inside ${project.build.directory}. how can access value of ${project.build.directory} inside unit test?
one way, think of, provide filtered properties file in test resources, holdes value. (i haven't tried yet, think should work.)
is there direct way access/ pass property value?
regards, florian
i've used success before. unit test still run if not using maven, target directory still created 2 dirs relative cwd of wherever tests run.
public file targetdir(){ string relpath = getclass().getprotectiondomain().getcodesource().getlocation().getfile(); file targetdir = new file(relpath+"../../target"); if(!targetdir.exists()) { targetdir.mkdir(); } return targetdir; }
Comments
Post a Comment