Skip to content

Single Stepping an Example

Chris Guest edited this page Nov 3, 2016 · 1 revision

IntelliJ

Using the Community or Ultimate Edition of IntelliJ we can single step through a Specification Script. Once again use a package manager such as brew to do so.

Now load IntelliJ

Goto File->Open and locate the Maven pom.xml in the "acceptance-tests" folder to import it. This will show the following dialog.

Picture

Once imported use "Build->Make Project"

Then use "Run->All Tests" to create a template configuration that can be altered. The tests will initially fail because of missing configuration. But once you do the initial run it will generate you a config you can edit.

Select the "All Tests" configuration and ensure that you pass both the browser profile and environment "-DbrowserProfile=chrome -Denv=default" (without quotes) in the VM options field.

Picture

Locate the AllTests.java file (use class search in the IDE) and change the tags field to "@google". This is to reduce the number of tests we are executing to only those that are @google tagged.

package com.acme.samples.acceptancetests;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(glue = { "io.jmcore", "com.acme" }, features = "src/test/resources/features", format = { "pretty",
        "json:target/cucumber-reports/cucumber.json" }, tags = { "@google" })
public class AllTests {
}

Now this is changed you can build and run "All tests" and see that lots less tests run.

Locate the HomeStepDef.java and put a breakpoint inside the I_have_opened_google() method

Picture

To debug press the little bug icon and you will now hit the breakpoint in the test.