mentby.com
Blog | Jobs | Help | Signup | Login

Maven fails to run any tests



I am only using the IDE Editor to edit.
Sorry for the mixup. I am only using the console and a simple bat file with
maven goals and phases.

I have made the following changes to the original Maven in 5 min example:
Changes to the .pom
I added the TestNG dependency and vertified that the jars were loaded in the
. m folder.
Added the surefire plugin as explained to be able to run tests: http://maven.apache.org/plugins/maven-surefire-plugin/usage.[..]
I "had" added a test src file AppTestNG.java and some others "as is" http://www.mkyong.com/maven/how-to-run-unit-test-with-maven/
and placed the new src files under the same test folder as AppTest.
However I removed them as soon as i discovered that Maven won't run any
tests for me
neither junit nor testng.
Result Tests run:0
Read: http://maven.apache.org/general.html#run-one-test http://maven.apache.org/plugins/maven-surefire-plugin/usage.[..] http://maven.apache.org/plugins/maven-surefire-plugin/exampl[..]

I even tried
java -cp target/mavenHelloWorld-1.0-SNAPSHOT.jar com.mycompany.app.AppTest
*****ERROR MESSAGE: Cannot find or load AppTest

Here is the bat file with the commands I use:

@echo off
echo *****************************************
echo Run a single test case
echo Expected Output: 6 test case run
echo *****ERROR MESSAGE: Failed to execute goal on
echo surefire plugin No tests were executed
echo *****************************************
mvn -Dtest=AppTestNG test
GOTO EndComment
@echo off
echo *****************************************
echo See maven-in-five-minutes
echo Using mc.bat
echo SWITCH TO MAVEN PROJECTS DIR:
echo C:\Users\GoGirl\_MavenProjects\mavenHelloWorld
echo *****************************************
echo.
CD C:\Users\GoGirl\_MavenProjects\mavenHelloWorld
echo *****************************************
echo CLEAN: Expected Output: Target Folder removed
echo *****************************************
echo.
mvn clean
echo.
@echo off
echo *****************************************
echo COMPILE:
echo Expected Output: Hello World
echo *****************************************
echo.
mvn compile
echo.
echo *****************************************
echo Test:
echo Expected Output: Compile tests (does not run them)
echo *****************************************
echo.
mvn test
echo.
echo *****************************************
echo BUILD & COMPILE ALL:
echo Rather than a goal, package is a phase
echo in the build lifecycle creating an executable jar
echo Expected output: Target folder created
echo *****************************************
echo.
mvn package
echo.
@echo off
echo *****************************************
echo Test the newly compiled and packaged JAR
echo using java -cp: Expected Output: Hello World
echo *****************************************
echo.
java -cp target/mavenHelloWorld-1.0-SNAPSHOT.jar com.mycompany.app.App
echo.
echo *****************************************
echo Test the newly compiled and packaged JAR
echo *****ERROR MESSAGE: Cannot find or load AppTest
echo *****************************************
echo.
java -cp target/mavenHelloWorld-1.0-SNAPSHOT.jar com.mycompany.app.AppTest
echo.
echo *****************************************
echo Compile all tests
echo Without running them
echo BUILD SUCCESS
echo *****************************************
echo.
mvn test-compile
echo: check package name matches directory structure
C:\Users\GoGirl\_MavenProjects\mavenHelloWorld\src\test\java\com\mycompany\app
:EndComment


Gogirl Sat, 18 Feb 2012 06:28:40 -0800

Sure fire expects test class names to begin or end with Test unless you
configure it otherwise... Rename your test and it will run ;-)

http://maven.apache.org/plugins/maven-surefire-plugin/exampl[..]

C:\Users\GoGirl\_MavenProjects\mavenHelloWorld\src\test\java\com\mycompany\app


Stephen Connolly Sat, 18 Feb 2012 07:38:24 -0800



Related Topics

Post a Comment