Closed kevinwee0712 closed 5 years ago
Hello,
You can debug the Courgette runner from the IDE but you will not be able to debug your test code when running in parallel.
Courgette creates a new thread for each test which means you cannot debug inside the thread from your IDE.
Thanks for the quick reply. Is there any way we could temporarily disable parallel so that we could debug a single test in IDE? I tried to set threads to 1, or even remove threads field from runner, neither of them works.
Courgette runs each test in a separate JVM so debugging is not possible. You will need to use the Cucumber IDE plugin or create a custom Cucumber runner for debugging.
You can debug the Cucumber test using the Cucumber for Java IntelliJ plugin
More reading info here
Excellent, will try both ways. Thanks for the reply. :)
First of all, I'm using the latest courgette-jvm as follows: compile 'io.github.prashant-ramcharan:courgette-jvm:3.3.0' When I try to debug my bdd automation steps, realised that if I set a breakpoint inside of courgette-jvm code, it could stop as expected. But if I set a breakpoint in my automation steps, it will be automatically bypassed and never stopped. Is this a known limitation? BTW, I'm using intellij.
Sample step snippet:
package automation;
import org.junit.Assert; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver;
import cucumber.api.java.en.Given;
public class Stepdefs { @Given("^I visit \"([^\"]*)\"$") public void iVisit(String url) { WebDriver webDriver = new ChromeDriver(); webDriver.get(url); <- if breakpoint set here, won't stop webDriver.quit(); } }
Sample feature file
Feature: Sample Test
@Regression Scenario: Flight booking first bdd test Given I visit "http://www.google.com" Then I visit "http://www.facebook.com"
build.gradle sample
repositories { mavenCentral() }
ext { seleniumVersion = '3.141.59' junitVersion = '4.12' }
dependencies { compile "junit:junit:${junitVersion}" compile 'io.github.prashant-ramcharan:courgette-jvm:3.3.0' compile "org.seleniumhq.selenium:selenium-java:${seleniumVersion}" compile "org.seleniumhq.selenium:selenium-support:${seleniumVersion}" }