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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -