Maven with Testing Project

69 views
Skip to first unread message

Gaurang shah

unread,
Sep 23, 2013, 9:09:49 AM9/23/13
to maven-...@googlegroups.com
Hi Guys, 

I have earlier used ANT in few project however now i am thinking to use Maven for my new project, however I am facing one problems. 

In ANT we have custom targets, so in one ANT project i can define as many custom target i want and include TASKS ( i.e. clean, compile, run .. ) So in my project need following targets

Smoke-Test
Regression-Test
E2E test
ModuleATest
ModuleBTest

However I didn't find anything like this in MAVEN, in Maven there are specific goals, and when i run TEST goal, it runs all the test inside test folder. Can someone help me to resolve this problem, else i will have to move back to ANT.

Gaurang shah

rmw...@gmail.com

unread,
Oct 20, 2013, 9:48:26 PM10/20/13
to maven-...@googlegroups.com
Hi Gaurang (et all),
This is my first interaction with this group. I have been scoping out php-maven for several months now that I am working as a php developer- prior to that I used Maven extensively in Java.

Someone else may have a better answer than me but I have dealt with a similar problem in the past (IE multi-stage QA process). I am going to go ahead and make as few assumptions as possible about your background. In maven you have several built in phases (IE pre-test, test, post-test, pre-integration-test, integration-test, post-integration-test, etc...) to these you can bind a number of goals (For instance, 'test'). Typically, the various plugins you invoke in your pom are tied to one (or more) of these phases and set of goals by default. For instance, the surefire plugin goals are typically executed during the test phase, the failsafe plugin during the integration-test phase, etc... However, this can be over ridden and these goals can be rebound to other phases (for instance, I worked on a project once where I rebound some goals from the failsafe plugin to the pre-test phase I think)- I have to admit, I am a little off the ball right now as far as the particulars, as I recall you can define your own custom goals and then execute them from the command line. The particulars can be found in sonatype's book. http://www.sonatype.com/resources/books/maven-the-complete-reference

That said, rebinding goals and swapping stuff around like that can get very confusing and lead to a lot of headaches. For better or worse, Maven is very draconian in how it enforces its project structure expectations. A better way of doing what I believe you want to do, is to use multi-module projects. Using multi-module projects, you can actually string together a bunch of separate projects and run them one after another. This is nice because you have the power of Maven's dependency management system to handle interproject dependencies- including specifying how one submodule depends on another. Another option to consider (or to be used at the same time) is the idea of maven profiles. Using profiles, you can specify parameters such as QA stage specific variables, profiles can also be run side by side together (IE are not mutually exclusive). The gotcha here is that you have to be careful where your test code is located relative to your aggregating pom or else Maven will not see your source code. 

Last thought, if you like Ant, Maven does support executing ant goals within Maven (http://maven.apache.org/plugins/maven-antrun-plugin/). Personally, I would urge you to consider maven-specific ways of getting done what you need to do first and then use Ant if absolutely necessary. 

Not sure if you wanted all of this information but I do hope it helps you. While you are looking at testing using maven (or ant), make sure you check out the maven site plugin and some of the various QA plugins which can be called from surefire. You can generate some awesome code analysis reports, etc...

rmw...@gmail.com

unread,
Oct 20, 2013, 9:50:47 PM10/20/13
to maven-...@googlegroups.com
" For instance, the surefire plugin goals are typically executed during the test phase, the failsafe plugin during the integration-test phase, etc..."

Woops, what I should have said here was something to the effect of the surefire plugin goals are typically executing during the test phases (IE pre-test, test, post-test). Though there are exceptions.


On Monday, September 23, 2013 6:09:49 AM UTC-7, Gaurang shah wrote:
Reply all
Reply to author
Forward
0 new messages