1

I'm trying to start automation on the web application that I'm currently manually testing. I was suggested to do it using BDD, so I started reseaching about it, and as I started writing my first features, I realized that there is just too much and I am getting overwhelmed.

My application was has like 10 menu items each one being a business unit, the one that I'm testing has like 9 - 10 sub menu items (screens) that resemble each a process of my business unit, and due to code reutilization, many of the screens I'm testing share components with other business units, so there were some bugs due to changes "out of my backlog", that's why I would like to test screen data validations. Also each screen has at least 3 - 7 sections (the sections shown depend on the data input) and each element of each section has different validations. Finally all the proccesses start with the same one, but some of then require more than two or three proccesses previously done.

Which should be my approach?

a) Should I try to write the features focusing the validation of each section separatedly? And at some point automate the full happy path of the proccess?

b) Or maybe I should stay into the general "flow" and write like i'm trying to do the whole proccess itself each time? Having tons of scenarios where I end the flow earlier because of the testing of the different validations?

Examples of what I thought: Suppose the first process of all, the test creation proccess, there you can create tests, you have for example, type STANDARD and type SPECIAL tests, type SPECIAL displays an additional section. Also for simplification SA => Section A. Parenthesis will be set of data for current section and type of test, so SA(STANDARD) will be the set of data for section A for a Standard Test.

   Background:
          Given I am in creation page

a) Feature: As A user I want to be able to create my tests
      Scenario: Completing SA with correct values
          When I complete with correct SA(STANDARD) values
          Then validation goes ok
          And SC is shown

      Scenario: Completing SA with correct values
          When I complete with correct SA(SPECIAL) values
          Then validation goes ok
          And SB is shown
          And SC is shown

      Scenario: Completing SA with incorrect values
          ... ... ... -> page validations

      Scenario: Partially completing SA 
          ... ... ... -> other page validations

      Scenario: Completing SC with correct values
          Given I completed SA with correct SA(STANDARD) values
          And SB and SC are shown
          When I complete SC with correct SC(STANDARD) values
          ... ... ...
     #And at some point I will automate the "happy path", well the happy path could be at the beginning though

b) Feature: As A user I want to be able to create my tests
      Scenario: Correct Creation of a STANDARD test
          When I complete SA with correct SA(STANDARD) values
          And I complete SC with correct SC(STANDARD) values
          And I create the test
          Then the test is created successfully

      Scenario: Correct Creation of a SPECIAL test
          When I complete SA with correct SA(SPECIAL) values
          And I complete SC with correct SC(SPECIAL) values
          And I complete SB with correct SB(SPECIAL) values
          And I create the test
          Then the test is created successfully

      Scenario: Attempting the creation of a STANDARD test with incorrect SA(STANDARD) values
          Given I am in creation page
          When I complete SA with incorrect SA(STANDARD) values
          And I create the test
          Then the test is not created
          And the screen shows validation errors on 

      Scenario: Attempting the creation of a STANDARD test with incorrect SB(STANDARD) values
          Given I am in creation page
          And I completed SA with correct SA(STANDARD) values
          When I complete SB with incorrect SB(STANDARD) values
          And I create the test
          Then the test is not created
          And the screen shows validation errors

Well, I know I wrote too much, I was trying to show what I've been thinking. Any help or suggestion is much appreciated.

1 Answer 1

0

One thing that may help is to take advantage of Scenario Outlines (jump to section 5 of the link), so you can separate your scenarios from the data you are using (e.g. "SA(STANDARD) values").

Scenario Outline: Add two numbers <num1> & <num2>
    Given I have a calculator
    When I add <num1> and <num2>
    Then the result should be <total>

  Examples: 
    | num1 | num2 | total |
    | -2 | 3 | 1 |
    | 10 | 15 | 25 |
    | 99 | -99 | 0 |
    | -1 | -10 | -11 |

Another point is to try avoid coupling your behavior to the screen elements, e.g. when you say "Given I am in creation page".

For instance, you can re-write:

Scenario: Attempting the creation of a STANDARD test with incorrect SA(STANDARD) values
          Given I am in creation page
          When I complete SA with incorrect SA(STANDARD) values
          And I create the test
          Then the test is not created
          And the screen shows validation errors on 

Like this

Scenario: Attempting the creation of a test with incorrect
          When I complete the test creation with the <values> values
          Then the test is not created
          And the screen shows the <error> message
Examples: 
    | values | error |
    | incorrect SA(STANDARD) | bla bla bla |
    | incorrect SB(STANDARD) | ha ha ha |

For a better understanding of behavior specification*, I would suggest the David Farley video on BDD.

* Note that you are not doing BDD, because you are not developing software driven by the specification - you are writing the specification and the software that verifies the specification adherence.

2
  • So, the screen acting different on each section should be handled in code? I mean, acording to the test type the validations are different even in the same sections. And sadly the error messages don't display in the same place for all the cases. They display below each one of the components.
    – WalterM
    May 18, 2021 at 16:53
  • First, it's good to separate moments of writing the specification (The .feature file) and writing the software that verifies the specification. Coupling the design of each onto the other may drive you to bad situations. "according to the test type, the validations are different even in the same sections." You can solve it with polymorphism. The code will call the validation procedure of an interface, and you can inject the real object with each specific implementation depending on the case. May 19, 2021 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.