Closed qaschevychelov closed 4 years ago
Serenity will only work with the JUnit runner
i managed to run tests with testng suite xml. I removed a line "@RunWith(CucumberWithSerenity.class)" and pass this.getClass() in the TestNGCucumberRunner constructor. All scenarios go to the Selenium Grid hub. But the hub passes all scenarious to one appium node every time. If i use parallel approach with "cucumber-jvm-parallel-plugin", then selenium grid hub passes scenarious correctly to nodes.
I'm not sure if this will work - the CucumberWithSerenity sets up Serenity, so if you don't have it, Serenity won't be enabled. Does the this.getClass()
replace this?
No this.getClass() refers to Cart class. Cart is a testNG runner. In this class i use methods with following annotations: @BeforeClass @Test @DataProvider @AfterClass (from testNG). DataProvider method (barcodes) return all feature files from path "src/test/resources/features/cart" into the method with Test annotation. And @Test method run all scenarious in all feature files. I investegated that when i use TestNGCucumberRunner, JUnit annotation @RunWith is omitted in test runner. But somehow (i dont understand how) first scenario goes to one appium node and runs correctly
Hi! I've faced such problem: I'm using 'cucumber-jvm-parallel-plugin' for parallel running feature files. But this approach create JVM per test runner. I decided to use testNG suite xml file, in which i link test runners. But in test runner i need to initialize TestNGCucumberRunner.
If i pass this.getClass() in the TestNGCucumberRunner constructor, then it will throw "[TestNG] WARN cucumber.runtime.SerenityBackend - It looks like you are running a feature using @RunWith(Cucumber.class) instead of @RunWith(CucumberWithSerenity.class). Are you sure this is what you meant to do?"
If i pass CucumberWithSerenity.class in the TestNGCucumberRunner constructor, then it will throw "None of the features at [classpath:net/serenitybdd/cucumber] matched the filters: [@ready]". I think i need somehow to switch classpath from classpath:net/serenitybdd/cucumber to a valid one.
Where did i go wrong?
My pom file: `
My project structure:
My test runner: `package featureRunners;
import androidUtils.DeviceFinder; import cucumber.api.CucumberOptions; import cucumber.api.testng.AbstractTestNGCucumberTests; import cucumber.api.testng.CucumberFeatureWrapper; import cucumber.api.testng.TestNGCucumberRunner; import net.serenitybdd.cucumber.CucumberWithSerenity; import org.junit.runner.RunWith; import org.junit.runners.model.InitializationError; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import testRail.com.gurock.testrail.APIException; import utils.DevicePreparation; import utils.Updater;
import java.io.File; import java.io.IOException;
/**
*/ @RunWith(CucumberWithSerenity.class) @CucumberOptions( features = {"src/test/resources/features/cart"} ) public class Cart extends AbstractTestNGCucumberTests { private TestNGCucumberRunner testNGCucumberRunner;
@BeforeClass(alwaysRun = true) public void setUpClass() throws IOException, APIException, InitializationError { testNGCucumberRunner = new TestNGCucumberRunner(CucumberWithSerenity.class);
}
@Test( groups = "cucumber", description = "Runs Cucumber Cart Feature", dataProvider = "barcodes" ) public void feature(CucumberFeatureWrapper cucumberFeature) { testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature()); }
@DataProvider public Object[][] barcodes() { return testNGCucumberRunner.provideFeatures(); }
@AfterClass(alwaysRun = true) public void tearDownClass() throws Exception { testNGCucumberRunner.finish(); }
public static void prepareDevice() { System.out.println("Runner " + "prepareDevice " + DeviceFinder.getUDID()); // get up DevicePreparation.invokeCmdCommand("adb -s " + DeviceFinder.getUDID() + " shell input keyevent 224"); // disable animations DevicePreparation.invokeCmdCommand("adb -s " + DeviceFinder.getUDID() + " shell settings put global window_animation_scale 0"); DevicePreparation.invokeCmdCommand("adb -s " + DeviceFinder.getUDID() + " shell settings put global transition_animation_scale 0"); DevicePreparation.invokeCmdCommand("adb -s " + DeviceFinder.getUDID() + " shell settings put global animator_duration_scale 0"); //enable Wifi DevicePreparation.invokeCmdCommand("adb -s " + DeviceFinder.getUDID() + " shell svc wifi enable"); System.out.println("Runner " + "End prepareDevice " + DeviceFinder.getUDID()); } }`
My suite xml: