How to implement selenium tests on Jenkins project for Maven / Java?

friends. I am trying to understand how selenium works. I wrote some tests with JUnit 4. These tests work fine when my application is running and I put it as the url localhost: 8077 where my application starts. All tests pass as I need them. But now I want my military builds to depend on these tests. After that, I want the automatic version (Jenkins) to also depend on the selenium tests. I don't understand some things:

  • Should selenium test be included in my application or should they be compiled in a separate application? (I read about Selenium Grid, but I'm not sure if I need this)?
  • I have one developer machine, one jenkins server and a production server. What are the required steps to implement a Selenium test? Which Url should be used in the test? Do I need to install Tomcat Server on the same server as Jenkins?
  • Can I invalidate a build and opt out of releasing to Jenkins if the selenium tests are not passed?
+3


source to share


2 answers


Should selenium test be included in my application or should they be compiled in a separate application? (I read about Selenium Grid, but I'm not sure if I need this)?

It depends on how you want to run your tests. The best practice is to call the test configuration inside your maven project and the tests will run during your build work. You can also call your maven target after the build is complete.

Selenium mesh is useful, but only if you have special machines that are properly configured to run these tests, otherwise your tests may fail frequently. You should consider running your tests remotely in the cloud using services like Saucelabs etc.

I have one developer machine, one jenkins server and a production server. What are the required steps to implement a Selenium test? Which Url should be used in the test? Do I need to install Tomcat Server on the same server as Jenkins?

Selenium tests can be implemented from Maven to Jenkins following a step from here , here and here .

Use Dev or Test URL to run the test.



I think you need Tomcat Server if you are hosting your application on Jenkins machine, otherwise you won't need it.

Is it possible to invalidate a build and drop a release on Jenkins if the selenium tests are not passed?

When you include the test configuration in your project configurations, the build may fail during the build job if your test fails. You can set how you want the build to continue when you experience a failure, such as a build failure or a warning build submission. You can also get notifications about a failed build.

Ex. Jenkins marks a good build as a failure due to a failed test

Jenkins plugins can be used based on needs.

You can read more about how to do integration tests here .

+1


source


I will do my best to answer your questions and hopefully clarify something for you.



  • From my experience, each test should be created as a new item and then configured to run after deploying or periodically deploying your application. No, you don't need selenium mesh. It is used to run tests in parallel.

  • You need to configure your computers as nodes on jenkins and install jenkins agent on slave machines. Setting up selenium tests is different depending on how you wrote the tests, for example I use maven as my build tool. So for every new test I only have to point to svn and give commands to start maven. A URL is whatever URL you use to access your application. There is a very good article on how to set up jenkins on your site, you can find it here

  • Yes.

+1


source







All Articles