In this post I am trying to resolve one issue of JUnit with Eclipse and Maven.
Sometimes while using JUnit with Eclipse and Maven we have to face certain issues. And one of them is whenever we try to run the independent test case it will run fine and will not give any type of error. But when we run to try to compile the whole project, the same test will not compile at all.
This is an annoying issue if someone does not know about the functionality of how Eclipse works with JUnit and Maven.
Since there is such no exception seen in file, but project compilation fails due to same file it is very frustrated for developer to figure out the issue. I am facing this issue and found a solution by googling around many forums.
Problem: You have created a JUnit test case in the project and it is running fine, but fails to compile the whole project when try to build using Maven.
Solution: Check that the test case you have created exist in the src/test/java folder and not in src/main/java. Very funny isn't it. Actually Maven compiles the files under src/main/java to target/classes and src/test/java to target/test-classes.
So whenever you try to build the project it encounters the JUnit test class but it will not able to compile. So, put file in src/test/java folder and the project will run smoothly :)
Thanks for reading blog.
Since there is such no exception seen in file, but project compilation fails due to same file it is very frustrated for developer to figure out the issue. I am facing this issue and found a solution by googling around many forums.
Problem: You have created a JUnit test case in the project and it is running fine, but fails to compile the whole project when try to build using Maven.
Solution: Check that the test case you have created exist in the src/test/java folder and not in src/main/java. Very funny isn't it. Actually Maven compiles the files under src/main/java to target/classes and src/test/java to target/test-classes.
So whenever you try to build the project it encounters the JUnit test class but it will not able to compile. So, put file in src/test/java folder and the project will run smoothly :)
Thanks for reading blog.
Comments
Post a Comment