Search code examples
seleniumsaucelabsallure

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?


Solution

  • 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.