Thursday 13th December 2018,
SQA²

BBT Test Case Optimization

Everett Khim October 14, 2014 BBT - How To No Comments
123rf-9271380_s

The methodology of BBT is to incorporate requirements which are interpreted as behaviors. The behavior is then broken down to Contexts, Constraints, and Outcomes which encircles a complete coverage of behavior and requirements.

Identifying the context(s) and outcome(s)

To identify the behavior of a system, we ask ourselves, “In order to validate the end result, what actions and conditions are required?” So, how do we begin identifying our behavior? The first step is to identify the expected result we are expecting to achieve when the conditions are met, this is known as an Outcome.

What is an Outcome?

                                An outcome is  a behavior of a system that is validated if conditions are TRUE

The second step is to identify the requirements needed to reach the outcome, in other words, what are the required contexts needed to be TRUE in order for us to validate the expected results?

What is a Context?

                                A context is a TRUE state or condition that influence the behavior of a system.

The last step is to apply logic in our behavior to provide accurate test coverage.  When you have a simple scenario such as two contexts (Example, user submits username and user submits password), we want to determine if both or one of the context is required for a user to reach the expected behavior or outcome(Example, Home page). In this case, we provide a logic to meet the condition (Example, And(^)) to meet the expected behavior.

 

 

Example of AND logic:

Given WHEN the user submits username AND user submits password THEN user lands on home page

Example of OR logic:

Given WHEN the user submits invalid username OR user submits invalid password THEN SSA message is presented

 

 

The logical difference between AND and OR in our example above would generate different results as AND condition requires both context to be TRUE, while OR condition requires at least one to be TRUE.

How do we graph Context(s) and Outcome(s)?

 

From our example, we have identified the context needed for the outcome to be TRUE. By allowing a visual representation of the behavior, we can quickly identify the possible combination without the cluster of test cases. We can achieve this by graphing our behavior; we first begin by creating the two contexts we have identified in our example.

BBT Context

BBT Context

Next we create an outcome,

BBT Context and Outcome

BBT Context and Outcome

Finally, we will apply the logic or condition for our outcome to be TRUE.

BBT Graph

BBT Graph with Context and Outcome

From this graph we can state that “User submits username” AND (represented as ^) “User submits password” are required to be TRUE for “User lands on Home page” to be TRUE.

 

It’s that simple.

 

Generating a Truth Table

By generating a Truth Table for the example above, we can prove we have full coverage for that behavior. Let us review, we started by identifying our systems behavior or expected results (outcome), then we identified the contexts required for our outcome to be True:

Expected Behavior:

                User successfully lands on home page WHEN providing valid username and password

Context(s):

                User submits username

                User submits password

Outcome(s):

                User lands on Home page

Event(s):

                Clicks on Submit button

Next, we generate a Truth Table to prove with the given contexts and outcome we can generate full test coverage for this behavior.

User submits username User submits password User lands on Home page
1 1 1
1 0 0
0 1 0
0 0 0

 

In the table above, we generated both positive and negative test cases from the context in our example. Let us begin by reviewing each row in our Truth Table. In Behavior Based Testing methodology, we realize our steps by stating GIVEN condition A AND condition B WHEN event THEN outcome TRUE. The first row states, GIVEN  ”User submits username” AND “User submits password”  WHEN ” WHEN Clicks on Submit button ” is TRUE THEN “User lands on Home page” is TRUE. As a result, our first test case is “Given user submits username AND user submits password WHEN Clicks on Submit button THEN user lands on Home page”. In the second row, we identify GIVEN “User submits username” is TRUE AND “User submits password” WHEN Clicks on Submit button is FALSE THEN “User lands on Home page” is FALSE, this will give us our second test case “Given user submits username AND NOT user submits password WHEN Clicks on Submit button THEN NOT user lands on Home page”. Our third row can be read as GIVEN “User submits username” is FALSE AND “User submits password” WHEN Clicks on Submit button is TRUE THEN “User lands on Home page” is FALSE;  notice “User lands on Home page” is false as our “AND” (^) logic requires both context to be TRUE for our outcome to be TRUE, with that said, our test case generated by the third row is “Given NOT user submits username AND user submits password WHEN Clicks on Submit button THEN user lands on Home page”. Lastly, GIVEN both “User submits username” and “User submits password” is FALSE THEN “User lands on Home page” WHEN Clicks on Submit button is FALSE. Our test case for the last row for our example is “Given NOT user submits username AND NOT user submits password WHEN Clicks on Submit button THEN user lands on Home page”.

Generated Test Cases:

Given user submits username AND user submits password WHEN Clicks on Submit button THEN user lands on Home page

Given user submits username AND NOT user submits password WHEN Clicks on Submit button THEN NOT user lands on Home page

Given NOT user submits username AND user submits password WHEN Clicks on Submit button THEN user lands on Home page

Given NOT user submits username AND NOT user submits password WHEN Clicks on Submit button THEN user lands on Home page

 

From this simple example we have demonstrated how Behavior Based Testing allows us to quickly and effectively generate positive and negative test cases from our original two context and one outcome. By identifying the behavior of the system and requirements needed for our expected behavior to be TRUE, in return we generate full test coverage for the example behavior. Behavior Based Testing methodology apply to even the most complex behavior once we identify the end results, the context required for our end results to be TRUE, and graphing our behavior.

Like this Article? Share it!

About The Author

Comments are closed.