Archive for the ‘maven’ Category

Why you NEED to become framiliar with Maven.

November 18th, 2010 No comments

If you program in Java, you NEED to become fluent in Maven.

Why?  Because it simplifies working on projects a lot. 


  • Lots of utilities that can be run on any and all maven projects at any time with only one command, and without downloading anything manual.
  • Generate Javadocs instantly.(mvn javadoc:javadoc)
  • Run all tests with one command and receive pretty html reports of your test results.(mvn test)
  • View Test Code coverage with one command and no downloading. (mvn cobertura:cobertra)
  • Almost instantly use the latest Java libraries, like Apache Commons. (IDE detects unknown class and prompts you to add a dependency to your project).
  • Do selenium testing with one command. (mvn selenium:start-server)
  • Generate web projects that include Hibernate, Spring, and more in minutes. (mvn archetype generate)
  • Run your tomcat projects with a single command. (mvn tomcat:run)
  • And more!!!  If you develop in Java,  learning Maven will increase productivity a lot.


Start off with this video:

Categories: java, maven, spring, web Tags:

MultiThreaded TestNG, Surefire Craziness.

June 30th, 2009 No comments

The Setup

Maven 2.0.9
Surefire 2.4.3
TestNG version 5.8

The Craziness

If you annotate a method to have an invocationCount of 2, and a threadPoolSize of 2, and your test fails in an @BeforeMethod or an @AfterMethod when run by surefire, the test run count reported by surefire will be inaccurate. Significantly innacurate at times.

For example:

package com.infusion.crm.application;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

* Created by IntelliJ IDEA.
* User: joey
* Date: Jun 29, 2009
* Time: 3:19:13 PM
* To change this template use File | Settings | File Templates.
public class TestThreadPoolSize {
public void before(){

public void test1(){

Returns the following from maven test:

Running TestSuite
Tests run: 8, Failures: 1, Errors: 0, Skipped: 7, Time elapsed: 10.298 sec <<< FAILURE! Results : Failed tests: before(com.infusion.crm.application.TestThreadPoolSize) Tests run: 8, Failures: 1, Errors: 0, Skipped: 7

This problem is also manifested if you create an AnnotationTransformer that forces the invocationCount and threadPoolSize of a test to both be greater then 1.

This bug is only manifested when multiple threads are used. If you set the invocation count to 20 and the thread pool size to 1, the bug does not appear.

Sometimes it is unpredictable and worse then just 2x the right number of tests. I ran a test, with 9 methods, and 4 threads, and a very exhaustive @BeforeMethod that takes several seconds to run. It failed repeatedly and said: 142 test run, 3 failed, 139 skipped.

Categories: java, maven, testng Tags: