How to run parallel test suites in TestNG - selenium

I am try to run parallel test suites using below command.
java -cp testng-6.3.1.jar;test.jar;selenium-server-standalone-2.18.0.jar org.testng.TestNG -suitethreadpoolsize 2 testng-vm1.xml testng-vm2.xml
When i execute above command, the last testng xml file only (i.e testng-vm2.xml) is running. But i want to run both xml files parallel .
As i know that the above command is getting from http://testng.org/doc/documentation-main.html#parallel-tests
Please let me know is it possible to run parallel suites through TestNG?

I think it's a better solution by creating a Maven Project and configuring it to run your tests in parallel.
More details:
Starting with Maven
http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
TestNG (and its parallel config)
http://maven.apache.org/plugins/maven-surefire-plugin/examples/testng.html

Related

How to run CI selenium side runner tests on Jenkins

I have a .side file generated by the Selenium IDE, which I need to run on CI using Jenkins.
I am running it as a build step with the following shell command:
selenium-side-runner /path/to/file.ide
The problem arises due to the fact that no matter if the selenium test fails, Jenkins always shows is as success.
In this thread it's suggested to upload the file as generic, but still, the commands to execute it are missing
How to upload a generic file into a Jenkins job?
I've found a possible solution to it on this posts, but I would appreciate having a cleaner way to solve this instead of parsing the results checking for errors.
How to mark a build unstable in Jenkins when running shell scripts
Is there a plugin able to run selenium .side files on Jenkins and this one showing the success/failures of the test?
You can generate a Junit test report file and then use the Jenkins Junit plugin after your tests execution.
selenium-side-runner --output-directory=results --output-format=junit
# Outputs results in `junit` frormat in `./results/projectName.xml'
Check the official documentation for more details.

Execute TestNG.xml in dry run mode via eclipse

Is there a way to execute TestNG.xml in dry run mode so that I can figure out what methods gets qualified for the test run. I am using Eclipse and intend to run the tests via testng.xml. How to configure Run Configurations for this.
Newbie to Selenium-TestNG and Eclipse
I tried to provide -Dtestng.mode.dryrun=true in Run Configurations -> Arguments tab under both Program argument and VM arguments
The run configurations had no effect on the execution. The tests were executed in normal fashion. I expected the configurations would just list test methods in the console
You are going to see all tests with no failures. That what you expect when you run testNg with the argument.
To check the dryrun argument works, make your test to fail. Then run your test with "-Dtestng.mode.dryrun=true". Add the argument in "VM arguments"
Also, check your version of testNG is 6.14 or higher

Parallel execution of features files : maven-failsafe-plugin vs cucumber-jvm-parallel-plugin

Currently I'm using maven-failsafe-plugin to run multiple feature files in parallel with Selenium Grid + nodes ( all running in docker containers )
I'm basic questions as below
when to use cucumber-jvm-parallel-plugin ?
what benefits / disadvantages of cucumber-jvm-parallel-plugin over maven-failsafe-plugin parallel execution ?
Thanks in advance.
Below is the answer
"A common approach for running Cucumber features in parallel is to create a suite of Cucumber runners, one for each suite of tests you wish to run in parallel. For maximum parallelism, there should be a runner per feature file.
This is a pain to maintain and not very DRY."
https://github.com/temyers/cucumber-jvm-parallel-plugin/issues/139
additional details -
..Despite its name cucumber-jvm-parallel-plugin does not run any tests, it just automatically generates the Cucumber runners for you. This saves you time from making empty runner files and also just by changing the config of the cucumber-jvm-parallel-plugin you can have brand new set of runner files..
copied from http://automationrhapsody.com/running-cucumber-tests-in-parallel/#comment-3455579028

Code to Run Multiple Selenium Webdriver JUnit Class In a Batch File

I have multiple selenium test classes. They are independent of each other.
Can anyone please tell me the code to put in a batch file to run multiple test class by simply clicking on the batch file?
Consider my java test classes are located in my local folder: "C:\WebDriver Effort\inspection\src\test\java\com".
Writing batch file is not big deal. First try to execute your testcases from command prompt.
If your test cases have main class you can execute like this.
cd C:\WebDriver_Effort\inspection\src\test\java\com\
javac Test1.java //compile testcase
java Test1 //running testcase
Make sure that selenium.jar is in your classpath otherwise mention the that while compiling.
javac -cp "Selenium-standaloneserver.jar" Test1.java //compile testcase
java -cp "Selenium-standaloneserver.jar" Test1 //running testcase
If you've written test cases in JUnit format follow the steps mentioned in this link

Running WEbDriver tests

So i have been writing Selenium tests for a while now and i have been running the only from the IDE untill now.
i would like to be able to write a script that runs all my tests sequentialy.
I am using the testng framework with eclipse and selenium-2.0b3 jar.
What i'd like is eventually to have a file like "runSeleniumTests.bat" witch just runs them and gives me some sort of report when in finishes.
if anyone has an idea, it will be very greatly appreciated, thanks :)
This has 4 options for how to run testng tests the xml file should include all your tests
http://testng.org/doc/documentation-main.html#running-testng
You could also try to use maven and as long as your tests are annotated correctly and in /src/test/java they will all be run for you with mvn integration-test (as long as you have the proper dependencies defined and I believe maven-surefire-plugin). This might be more difficult to setup initially but usually pays off.