TeamCity + Maven Project doesn't perform the tests

Hello guys!

I'm new here. I'm starting to use the tools IntelliJ, YouTrack and TeamCity. I am also new to the Java world. I also have no experience with Maven. Lots of new stuff to learn.

I set up a continuous integration server with TeamCity. I'm trying to set up a project using Maven.

I had some difficulties, then follow the step by step tutorial book "7 TeamCity Continuous Integration Essentials". However, even following the tutorial I could not make it work right. Something is wrong.

My problem is that TeamCity application compiles but does not run the tests.

The book tells how to configure Maven Goals: clean compile install

I do not know if this is correct, because in the book, after setting up the server so it runs all tests. On my server, the tests are not performed.

At the moment I have 2 tests. One of them is passing and the other does not. Just to test.

If I run in IntelliJ the maven goal "test" it displays this message:
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.051 sec <<< FAILURE!

Exactly what I expected.

In TeamCity server the result of Build is: Success
No test information.

In BuildLog of TeamCity displays these messages:
----------------
[INFO] --- maven-surefire-plugin: 2.10: test (default-test) @ sample ---
[INFO] No tests to run.
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
----------------

I figured that the configuration of the Maven goals were wrong, so I switched to just: test

And now the result of the build is: Tests passed: 1

The log shows this information:
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.056 sec

I do not know what's wrong. Why running in the TeamCity he does not find the 2 tests?

What should be the goals of Maven settings in TeamCity configuration?



OBS: Attached pom file

Thank you!

Attachment(s):
pom.xml
6 comments
Comment actions Permalink

Roberto,

Try running this command in your projects directory:

mvn clean test

How many tests are reported in maven output?

0
Comment actions Permalink

None.

The result is this:

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sample Maven Webapp 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ sample ---
[INFO] Deleting D:\trein\projetos\sample\target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ sample ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ sample ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\trein\projetos\sample\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ sample ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\trein\projetos\sample\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ sample ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ sample ---
[INFO] No tests to run.
[INFO] Surefire report directory: D:\trein\projetos\sample\target\surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.644s
[INFO] Finished at: Thu Mar 14 13:21:24 BRT 2013
[INFO] Final Memory: 9M/121M
[INFO] ------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Attached the project;



Attachment(s):
sample.rar.zip
0
Comment actions Permalink

Hi Roberto,

There was a minor issue with maven project structure. You should place sources of your tests under 'src/test/java' path, not directly to 'src/test'

Please, update your project.

Fixed sample is attached.



Attachment(s):
sample_fixed.zip
0
Comment actions Permalink

Thank you! It worked!

The strange thing is that this structure was created by maven!

0
Comment actions Permalink

Possibly, the archetype is corrupted.  This problem deserves being reported to archetype's author.

0
Comment actions Permalink

Probably. Thank you.

0

Please sign in to leave a comment.