Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Maven archetype "webapp-javaee6" question

 
Ranch Hand
Posts: 136
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author & internet detective
Posts: 41086
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.)
 
Sujoy Choudhury
Ranch Hand
Posts: 136
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sujoy Choudhury
Ranch Hand
Posts: 136
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic