Search code examples
javaeclipsemavenseleniumant

File structure for Maven base selenium project?


I have been using Ant (Normal Java Project) to run my Selenium (java) test cases using Eclipse IDE. But now I am using Maven project; I was told that it has better structure, however I don't understand what benefit I'll get with structure.
When I was using Ant, I had to create packages, folders manually but now when I moved to Maven I've got all folders, packages created by Maven itself.

How it looks:it is a maven-archetype-quickstart project
enter image description here

Queries:
1. Is this the only reason I should be using Maven, that it creates folders and packages for me (I know that I dont have to create library folder to put essential jars; I can use Maven repo)?
2. What is the meaning of these created folders, How I should be using them ideally?
3. Does Maven provides the most optimum structure maven-archetype-quickstart?

Note: I am a tester and I am pursuing Selenium Automation testing. Dont mind if this is not a nice question, I am a beginner.


Solution

  • 1.: Folders and packages, is not the only benefit. It also gives you a proper project structure. This is convention over configuration, since when you understood the structure of one Maven project, you won't get lost in any other project. I suggest to read a book about Maven, for instance "Better Builds with Maven".

    2.: src/main/java: all your source classes, src/main/resource: addtional resources, src/test/java: test classes, src/test/resources: additional resources for the test

    3.: The quickstart is good for a starter. It is true that it has a quite old JUnit dependency and creates some default folders and classes. But if you want a different type of project there a lot of other archetypes out there. If you use the command

    mvn archetype:generate -DgroupId=test -DartifactId=test

    you will get a long list of available archetypes to choose from.

    If you use eclipse you can also select the archetype in a dialog.

    There is a archetype for Selenium projects, but it requires understanding of Maven and Git.