0

I running locally a Maven/Selenium/Java/TestNG test project for a bit, and I wish I could push it to Docker/Kube so that it will be executed remotely, without using my machine's power and also in order to be able to be used "without" me.

My concern is that every time I look for examples or documentation about it, I can only find explanation about running the driver interactions remotely using Selenium Grid or similar. But never about running the test code by itself remotely. Any tutorials or examples about it?

I plan on using Browserstack (or a similar solution with remote driver) for driver interactions, and I already run a local Allure server for reporting, so I only need to containerise the test code, and I wonder if anyone of you has already done it and how. Any suggestion is welcome :)

Batou
  • 98
  • 1
  • 8
  • 1
    Maven already has goals to run tests (e.g. `mvn test` etc.). You could look for how to build your application in a container and do something similar to run the tests only (by default maven builds already run any tests they find). – Thomas Mar 15 '21 at 10:14
  • > how to build your application in a container Yes, that's basically what I'm looking for here. Likely I miss-understood most articles I read, but I could find a couple java apps container help (like JIB), but nothing specific to java test apps. – Batou Mar 15 '21 at 13:04

2 Answers2

1

You can do that by multiple approches, but first you need to create a dockerfile

Using a specific mvn plugin spotify and that needs to be configured in your pom file.

Or just by just using docker commands, https://docs.docker.com/engine/reference/commandline/build/#:~:text=The%20docker%20build%20command%20builds%20Docker%20images%20from,instruction%20to%20reference%20a%20file%20in%20the%20context.

  • Thanks for the directions. Indeed, the Spotify plugin looks promising, but I still can't figure how to make it work, there must be some prerequisites not mentioned. I guess my quest for a more complete example or tutorial is not over, but I have new leads now :) – Batou Mar 16 '21 at 14:00
0

To run selenium you have to see the command line option. You can directly run using testng as per the below discussion:

How to run TestNG from command line

But as you are already using maven for build management, you can use surefire-plugin and run mvn test to execute the test. see the discussion at:

How to run testng.xml from Maven command line

When ever you integrate tests or any other tools in CI/CD or any other such tools see for command line options. See how you can execute test from command line

PDHide
  • 18,113
  • 2
  • 31
  • 46
  • Thanks! I'm already using surefire-plugin and run tests from command line. Basically, I have a bash file doing `mvn clean test site` and handling other options like testgroups, headless, test environment address, retries etc. But running test from command line does not mean it's running remotely. Basicaly, if I shut down my WIFI/Mac during execution, I lose everything ^^ – Batou Mar 15 '21 at 13:00
  • @Batou thats why you use ci/cd solution which deploys the script to an agent and starts the test locally on that agent – PDHide Mar 15 '21 at 13:03
  • use jenkins like solutiuons – PDHide Mar 15 '21 at 13:03
  • Unfortunately, Jenkins is out of question. I need to use Docker. – Batou Mar 16 '21 at 14:11