2

When we use karate with cucumber reporting, the steps we see in the report are technical For example:

@mobile
  Scenario: test login

    Given driver { webDriverSession: { desiredCapabilities : "#(android.desiredConfig)"} }

    And retry(2, 2000).waitFor("//android.widget.TextView[@text='Comenzar']").click()

    And retry(2, 1000).waitFor("//android.widget.TextView[@text='Ingresar a mi cuenta']").click()
    ....

with resulting report: report

The problem with the report, it is showing technical info, which is useless for business or non techincal people.

Is there a way to customize the Step text in order to get a meaningful info?

Something like:

@mobile
  Scenario: test login

    Given driver { webDriverSession: { desiredCapabilities : "#(android.desiredConfig)"} } // When I launch app

    And retry(2, 2000).waitFor("//android.widget.TextView[@text='Comenzar']").click() // And click on button

    And retry(2, 1000).waitFor("//android.widget.TextView[@text='Ingresar a mi cuenta']").click() // And click on button ..

    ....
Jarp
  • 21
  • 3

1 Answers1

0

You've automated a manual test script. And while this is useful, there are several downsides. As you've discovered just now. And unfortunately only removing the technical details won't improve the situation much.

To do BDD you must start with a human readable description of the system. Then implement the technical details such as launching the app and clicking buttons next to that description, not as part of it.

This means that Karate is probably not the right tool for you. You could consider using Cucumber.

But even with Cucumber you're not quite there yet. Consider these scenarios:

Scenario: 
  Given I launch app
  And I click the "Widget" button
  When I click the "Add Widget" button
  And 
       ...42 more lines to create new widgets
  Then Widgets are sorted alphabetically 
  When I click the "Sort by creation date"
  Then Widgets are sorted by creation date
Scenario: 
  When widgets are created in a random order
  Then the widgets are listed alphabetically
  And can be sorted by creation date

Both are Cucumber scenarios.

The first scenario describes all the steps someone would have to take to achieve the result. It is human readable, and can be understood by non-experts. But it is also long, boring and hides the intent of the feature in all the details.

The second scenario describes the same thing, but describes it at a level you would explain it to a collegue.

This takes a bit of a mindshift to get right. So it might be worth reading more about BDD.

M.P. Korstanje
  • 10,426
  • 3
  • 36
  • 58
  • You are correct, but with cucumber, we will have to put a lot of effort into implementing java classes and glue code to support the steps. Our problem is only in the report output where we would have to have a better description of what happened in the scenario. – Jarp Mar 07 '23 at 14:02
  • @Jarp Karate is **NOT** BDD, please refer this, and consider using another tool if needed: https://stackoverflow.com/a/47799207/143475 – Peter Thomas Mar 07 '23 at 14:26
  • @Jarp maybe you can make a tool that connects your plain text definitions to your implementation in Karate? – M.P. Korstanje Mar 07 '23 at 14:37
  • One alternative I've found is, using "comments" but it is not so good.. they are yellow lines in the report. – Jarp Mar 07 '23 at 22:26