• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where to place Selenium tests in separate maven project

 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

We have a requirement where we need to create a different maven project just to write selenium tests for some other project. Now my question is ideally where should the tests located, in "src/main/java" or in "src/test/java" ? My colleague already committed tests in "test" folder saying we can easily run this tests just by shooting "mvn test" on command prompt.

Though I do not like this approach, I want to keep test in "src/main" folder, because -
1. I like to treat this tests as a production code.
2. What if in future I want to package it as a jar and pass it to some other nightly build server to run tests against my web app?
3. I would like to use "src/main/test" either for writing any test suite around my web tests OR to write any unit tests for web test.

So what would you guys suggest ? Any thoughts?
 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

My suggestion is to keep with the standard structure for a maven project (see here).
If you don't use these structures you are:
a) Probably going to have to make some configuration changes to maven in order for it to know where the tests are located because you are not using the usual place. (If you're not forced to make changes then why complicate your maven configuration)
b) Make it harder for anyone used to maven as the folders won't be as you would expect in a maven project

In answer to your question 2, you can have your app deployed to the server during the maven build and then run your tests against it all within maven. You can in maven build a jar with your tests in it so if this would be what you needed you can do it as well.

Sean

 
Ranch Hand
Posts: 32
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

Using "src/test/java" is not a bad idea. I can't imagine a scenario where you'd have to package them as a jar. If you going to run them on some kind of CI server then you'd probably use maven anyway. Also why would you ever need to write unit tests for selenium tests?

The way I've done it in the past is using something like "src/acceptance-test/java", but that requires some adjustments in your build script and ide.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sean Clark wrote:My suggestion is to keep with the standard structure for a maven project (see here).


Sean, I'm not changing the standard dir structure. I'm just want to decide where to keep web tests "src/main/java" or "src/test/java"?

Sean Clark wrote:In answer to your question 2, you can have your app deployed to the server during the maven build and then run your tests against it all within maven.


yeah, right; but this looks great if my web tests are in same maven project and not located somewhere in dedicated web test project.
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

Sagar Rohankar wrote:Sean, I'm not changing the standard dir structure. I'm just want to decide where to keep web tests "src/main/java" or "src/test/java"?


You're splitting hairs here, you are wanting to use a standard application code folder to store tests, you are changing what that folder does and therefore I think you are changing the standard directory structure. You would need to configure maven not to pick up your web tests otherwise you would end up with them in your WAR file. More effort than it is worth I feel and that is my suggestion. If you wish to take another route then do.

Sagar Rohankar wrote:yeah, right; but this looks great if my web tests are in same maven project and not located somewhere in dedicated web test project.


If you want to include the tests in another project then you could do that through maven by adding a dependency to your main projects test classes jar (you need to configure it to create a jar for the tests.)

I'm not looking to get into a debate, you asked for suggestions and these are mine, if you don't wish to take any notice then you are welcome to.

Sean
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcin Kwiatkowski wrote:Also why would you ever need to write unit tests for selenium tests?


Well, just in case I ended up writing selenium pages using page object pattern and if those pages contains some method with some logic. You never know when you're tempted to write unit tests

Marcin Kwiatkowski wrote:The way I've done it in the past is using something like "src/acceptance-test/java", but that requires some adjustments in your build script and ide.


I wish it could be done that way like a separate package "*/integration/*"
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sean Clark wrote:

Sagar Rohankar wrote:Sean, I'm not changing the standard dir structure. I'm just want to decide where to keep web tests "src/main/java" or "src/test/java"?

You're splitting hairs here, you are wanting to use a standard application code folder to store tests, you are changing what that folder does and therefore I think you are changing the standard directory structure.


Ohh, I thought you saying that I'm changing the dir name. OK. No issues.

Sean Clark wrote:
You would need to configure maven not to pick up your web tests otherwise you would end up with them in your WAR file.


No, It will not, because its a separate jar type project only for web tests.

Sean Clark wrote:

Sagar Rohankar wrote:yeah, right; but this looks great if my web tests are in same maven project and not located somewhere in dedicated web test project.


If you want to include the tests in another project then you could do that through maven by adding a dependency to your main projects test classes jar (you need to configure it to create a jar for the tests.)


That's look like a one great solution, I can certainly add "web test" dependency like this

and my web app project build a war, run a jetty, deploy the war and execute the web tests against it.
Thanks

reply
    Bookmark Topic Watch Topic
  • New Topic