This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
If you have your tests in a "non-standard" location, you do need to tell JUnit where they are. This is actually move of a Maven question than a JUnit one so moving to our Builds forum. This testing forum will link to the new location making it easy to find.
When you create src/test/java, did you move your unit tests to that directory?
It would also help if you post the error that you are now getting. If it is still the same as the original error, then you have not moved all of the unit tests out of src/java/main. Your dependency on junit has a scope of test which means that junit will not be included in the classpath when src/main/java is compiled; instead is is included only when src/text/main ois compiled and when the unit tests are run.
i have moved the test class in the directory src/test/java.My junit test in pom.xml is defined as follows:
I had also changed the plugin in my pom.xml:
The skipTest tag was true before i have changed it to false, this was why it was skipping the test. However when the junit test should fail and when i run mvn clean install comand it gives me a build success message. According to the log it seems that there is no junit class to test.
Try running mvn with the -X option and see if that gives a clue as to what is going on. If you can't tell anything from that, run it again with -X and redirect both stderr and stdout to a file and attach that file.
Also, post the full file and directory tree for your project (you can ignore the target directory). Base on your directory names I suspect you are running Windows, so to get the directory tree run this from the project's basedir:
And attach the pom.xml file.
Either you are doing something incorrectly or there is something very strange going on. But I will need access to the entire project to be able to tell.
If you cannot do this because of the proprietary nature of your code, create a simple sample project that exhibits the same behavior and post the information about that project.
Joined: Sep 02, 2011
Thanks a lot for you advice Peter. Now its resolved basically it was ignoring my test class because of the naming convention. It was Junit_TestSQL.java instead my class should start with the word Test, for instance TestJunitsql.java. When my test class start with the word Test it recognizes it as a JUNIT class test. I don't know why it does that but it did resolved my problem.
This sounds as if JUnit 3.x was used to run the unit tests; if I recall correctly it required the test classes to start with the word Test (or was it that the methods had to start with the word "test"?). None of my unit tests start with Test.
Or perhaps is has something to do with the version of the surefire plugin that you are using. What version of Maven are you running? Or it could be the JVM version; hopefully you are using at least version 1.5.
author & internet detective