How does parallelism work in the JUnit test framework? - selenium

How does parallelism work in the JUnit test framework?
How can I run multiple tests in parallel in JUnit?

Or you can simply start two Runners/JUnitcores in different Threads.

You can use Maven and configure it to run your test suite in parallel. You can configure it to run your tests in parallel by method or by classes. See Running JUnit tests in parallel with Maven for more information.

Related

Is it possible to run cucumber scenarios in parallel with CucumberJS and WEbdriverIO?

Is it possible to run cucumber scenarios in parallel with CucumberJS and WEbdriverIO while executing test scenarios on mobile devices?
We are executing feature files in Parallel as of now.
Running scenarios in parallel may not be possible as webdriverio and cucumber integration is using webdriverio runner.
Cheers!

How to run junit Selenium tests in parallel at Sauce Labs together with AllureTestRunner?

We use AllureTestRunner (https://github.com/allure-examples/allure-gradle-junit-example/blob/master/src/test/java/ru/yandex/qatools/allure/junit/BaseTest.java) to run junit selenium tests and generate allure reports.
And also we need to run them in parallel at Sauce Labs. There is runner for this: ConcurrentParameterized(https://github.com/saucelabs-sample-test-frameworks/Java-Junit-Selenium/blob/master/src/test/java/com/yourcompany/Tests/TestBase.java).
JUnit does not allow to use several #RunWith annotations.
Is it possible to combine two runners?
The problem is that there is no way to add listener to JUnit using Gradle. There are few workarounds available. The first one is use custom Runner that adds listener, the other one - use AspectJ magic to get this done. For more details you can see the following Gradle issue https://github.com/gradle/gradle/issues/1330
At the moment there is a Gradle plugin https://github.com/d10xa/gradle-allure-plugin that can add listener to JUnit using AspectJ. So simply remove AllureTestRunner and use plugin instead.
Update
New Allure Gradle plugin that supports Allure 2 is available now. See the docs https://docs.qameta.io/allure/2.0/#_gradle_3 for more details.

Is it possible to use Serenity with Cucumber-JVM for parallel test run?

I am using Serenity with Cucumber-JVM. Can I configure my tests to run in parallel to reduce execution time?
Cucumber-jvm is not thread-safe. That being said, you can look here and here for a solution that assigns a test runner to each feature file.

how to use selenium grid with Specflow and Nunit and Webdriver (in DotNet version)

Presently we built a Automation framework which uses Selenium Webdriver+ specflow + Nunit, and we suing bamboo as our CI to run our Job against our every build.
we written a build.xml to handle our targets (like clean, init, install latest build, run Selenium scripts, uninstall build. etc)
ant command will read the tag name from the build.xml and runs the respective feature/scenarios based on Tags (like #smoke, #Regression)with Nunit in CI machine.
Now our requirement is to use Selenium Grid to divide scripts into different machine and execute with above set-up. Grid has to divide the scripts based on feature file or based on Tags.How to achieve this.
Is there any thing need to done under [BeforeFeature] and [BeforeScenario] ?
If you provide in details steps or any link which explains detail steps that would be a great help.
Please any one can help in this regards.
Thanks,
Ashok
You have misunderstood the role Grid plays in distributed parallel testing. It does not "divide the scripts", but simply provides a single hub resource through which multiple tests can open concurrent sessions.
It is the role of the test runner (in your case Specflow) to divide tests and start multiple threads.
I believe that you require SpecFlow+ (http://www.specflow.org/plus/), but this does have a license cost.
It should be possible to create your own multithread test runner for Specflow but will require programming and technical knowledge.
If you want a free open source approach to parallel test execution in DotNet, then there is MbUnit (http://code.google.com/p/mb-unit) but this would require you to rewrite your tests

Running a smoke set of JUnit Selenium tests in Jenkins

How could I easily run only a smoke set of JUnit Selenium tests in Jenkins? Ant is used to execute tests, but I haven't found a way to annotate tests in JUnit and Java. In .NET and C# tests can be annotated, and easily grouped and categorized. I could of course set the Ant target to execute a Java package called "SmokeTests" and have the smoke tests there, but then the smoke tests would reside in two places (duplicate): smoke package and their original package where they belong to.
Any help appreciated!
In the last versions of JUnit, there is a way to annotate tests.
They call it categories: https://github.com/junit-team/junit/wiki/Categories
You should be able to create a "smoke" category and launch only this one from Jenkins.