cucumberserenity-bdd

Serenity BDD: What is the best approach to go with while doing automation with serenity BDD? Junit or Cucumber?


I want to implement Serenity BDD for my project. There are 3 ways to do it. Cucumber, junit or Jbehave.

Which will be the best one to go with? Some of my tests are data-driven.(up to 40-50 records).If I need to implement that with cucumber then I need to pass data from examples (Scenario outline). I think It's incovenient to pass all data from feature file.

I am doing it currently with junit. just thought whether it could more better with Cucumber or not?


Solution

  • There is no best approach, I guess you've already known that. Below are some points to help you choose the better in your context.

    If your team goes with truely BDD, that means you have feature, user story, examples to demonstrate system functions, then you definitely should go with cucumber:

    1. You've already have examples (don't need to re-write)
    2. BA, Dev, Tester and other stakeholder understand your tests when seeing the serenity report.

    Ok, now that you know that BDD is about discovery, collaboration and examples (and not testing), let’s take a look at Cucumber.

    Cucumber docs

    But if other members (PM, customer) only care the number of the tests, pass or fail, then go with JUnit. You don't need to write and maintain the human-friendly feature files to make test run. You can achieve the same thing by @Step and @Steps in JUnit.

    Both approachs are able to do data-driven test easily,

    1. scenarios outline in Cucumber will map to List or Map.
    2. JUnit 5 convert @Source to any object you want. It seems JUnit is more dynamic.