aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven archetype Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven archetype "webapp-javaee6" question" Watch "Maven archetype "webapp-javaee6" question" New topic
Author

Maven archetype "webapp-javaee6" question

Sujoy Choudhury
Ranch Hand

Joined: Sep 17, 2008
Posts: 136

Hi All,
The Maven (I am using version 3.0.3) archetype "webapp-javaee6" doesn't create any test folder.
Also the WEB-INF/META-INF folders are not pre-created.

How would I test my application?
I have created a "test" folder under src/main but my test class is not getting invoked.

What am I missing here?

Thanks in advance.


Thanks and Regards,
~Sujoy
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30917
    
158

Sujoy Choudhury wrote:I have created a "test" folder under src/main but my test class is not getting invoked.

The Maven directory structure assumes you are using src/test/java for your JUnit tests.

Also check your effective pom to make sure surefire or failsafe or there (depending on whether you have unit or integration tests.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sujoy Choudhury
Ranch Hand

Joined: Sep 17, 2008
Posts: 136

Thanks Jeanne. That helped. Now my Test class is getting invoked.

My question is:
Why didn't Maven create those test folders automatically?
But Maven did create test folders for simple "jar" kind of projects.
But for "webapp-javaee6" and "war" type it didn't.

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

If you use an archetype to create a project, then you get only what the designers of the archetype have provided. I have often found that many Java EE archetypes don't include the test directory structure. But there is nothing that says you can't create the directory yourself. My best suggestion is to create your own archetypes that contain everything you want. That's what I do, then I get a POM with all the settings that I want, a lot of boilerplate code, and lots of other things that I typically add to any of my web projects, all at the push of a button.


JBoss In Action
Sujoy Choudhury
Ranch Hand

Joined: Sep 17, 2008
Posts: 136

Thanks Peter for your response.

As per Maven's idea of "Convention over Configuration" why would Maven let developers decide where would they want the test folder?
These should be fixed as per Maven.

It's not a big deal, but anyway, thanks for your reply.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

In Maven you can move any of the folders to different locations. But you do so at your own peril because some plugins are not as good as looking up the configured location, instead relying on the default location.

Also, the absence of a test directory doesn't mean that something is amiss. Perhaps the archetype authors assumed that it is too difficult (or not possible) to write unit tests for that kind of web app (yeah, bad assumption). There are a lot of other conventional directories that are also missing from most archetypes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maven archetype "webapp-javaee6" question