You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by vy...@planwerk6.de on 2007/04/20 14:25:09 UTC

maven junit and eclipse

i have set up my pom with profiles and property filters
My src/main/resources/jdbc.properties file looks like this 

jdbc.driverClassName=org.postgresql.Driver
jdbc.url=jdbc:postgresql://${database.host}:5432/${database.name}
jdbc.username=${database.user}
jdbc.password=${database.password}

and is handled by 

  mvn process-resources 

which filters properties and copies the file to target/classes. everything 
works fine.

No i have a UnitTest which needs to load this jdbc.property file. Running with 
mvn test is ok, running UnitTest inside Eclipse doesn't work as it tries to 
load from src/main/resources/jdbc.properties and not 
target/classes/jdbc.properties

Is there a way to let Junit Test Cases inside Eclipse respect the maven 
classpath? It's so convinient to press Shift-Alt-X T to run the unit test i 
just dont want to miss it. Any suggestions?

kind regards,
janning

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


Re: maven junit and eclipse

Posted by vy...@planwerk6.de.
Hi,

Am Freitag, 20. April 2007 14:25 schrieb vygen@planwerk6.de:
> i have set up my pom with profiles and property filters
> My src/main/resources/jdbc.properties file looks like this
>
> jdbc.driverClassName=org.postgresql.Driver
> jdbc.url=jdbc:postgresql://${database.host}:5432/${database.name}
> jdbc.username=${database.user}
> jdbc.password=${database.password}
>
> and is handled by
>
>   mvn process-resources
>
> which filters properties and copies the file to target/classes. everything
> works fine.
>
> No i have a UnitTest which needs to load this jdbc.property file. Running
> with mvn test is ok, running UnitTest inside Eclipse doesn't work as it
> tries to load from src/main/resources/jdbc.properties and not
> target/classes/jdbc.properties
>
> Is there a way to let Junit Test Cases inside Eclipse respect the maven
> classpath? It's so convinient to press Shift-Alt-X T to run the unit test i
> just dont want to miss it. Any suggestions?

i found the solution by myself: mvn test used other classpath than junit 
inside eclipse. i checked my build path configuration in .classpath and tried 
it like this:

<classpath>
        <classpathentry kind="src" path="src/main/java"/>
        <classpathentry kind="src" output="target/test-classes" 
path="src/test/java"/>
        <classpathentry excluding="**" kind="src" output="target/classes" 
path="src/main/resources"/>
        <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry kind="con" 
path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
        <classpathentry kind="output" path="target/classes"/>
</classpath>

after cleaning the project and restarting eclipse everything worked fine. 
All you do need now is running mvn process-resources and repeat it if chaning 
some resources before you run any unit test. 

The maven eclipse plugin sets the wrong .classpath entries if you do 
maven>update source folders

kind regards,
janning

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