Cause-Effect Graphing Basics

Tutorial 3 of 5

Cause-Effect Graphing Basics

1. Introduction

This tutorial aims to introduce you to the basics of Cause-Effect Graphing, a structured and systematic approach to generating test cases. It's a black-box testing technique used in system testing and integration testing.

Goals of this Tutorial:

  • Understand what cause-effect graphing is and its benefits
  • Learn how to create a cause-effect graph
  • Translate cause-effect graphs into decision tables
  • Understand how to generate test cases from cause-effect graphs

Prerequisites:

  • Basic knowledge of software testing concepts
  • Understanding of decision tables is beneficial but not mandatory

2. Step-by-Step Guide

What is Cause-Effect Graphing?

Cause-Effect Graphing is a testing technique that visualizes the relationship between different conditions (causes) and their outcomes (effects). The graph is a directed graph with nodes representing causes and effects, and the edges represent the relations between them.

Creating a Cause-Effect Graph

Creating a cause-effect graph involves the following steps:

  1. Identify and list down all the causes (inputs) and effects (outputs).
  2. Draw the cause-effect graph using nodes and edges.
  3. Simplify the graph if necessary by eliminating redundant conditions and effects.

Translating Cause-Effect Graphs into Decision Tables

A decision table is a good way to deal with different combination inputs with their associated outputs for a given system. It's a structured exercise to prepare test cases from a complex nested if-else condition.

  1. Write down all the causes and effects in a table format.
  2. Map the relations between causes and effects.
  3. Verify the table for completeness and correctness.

Generating Test Cases from Cause-Effect Graphs

The final step is to generate the test cases. Each path from cause to effect in the graph represents a potential test case.

3. Code Examples

Since cause-effect graphing is a testing technique, it is more about design and does not directly involve coding. However, understanding how test cases derived from cause-effect graphing would look in code can be beneficial.

Example 1: Simple Login System

# Let's consider a simple login system with two causes: 'valid_username' and 'valid_password'. 
# The effect is 'access_granted'.

# Test Case 1: Both username and password are valid
valid_username = True
valid_password = True

if valid_username and valid_password:
    access_granted = True
else:
    access_granted = False

print(access_granted)  # Expected output is True (access is granted)

# Test Case 2: Username is valid, but password is not
valid_username = True
valid_password = False

if valid_username and valid_password:
    access_granted = True
else:
    access_granted = False

print(access_granted)  # Expected output is False (access is not granted)

4. Summary

In this tutorial, we've covered the basics of cause-effect graphing, how to create a cause-effect graph, how to translate it into a decision table, and how to generate test cases from it. We also went through a simple example of how test cases derived from cause-effect graphing would look in code.

5. Practice Exercises

  1. Create a cause-effect graph for a system that takes three inputs: a, b, and c. The system outputs True if at least two inputs are True. Generate all possible test cases.

  2. Create a cause-effect graph for a system that takes a number as input. The system outputs 'positive' if the number is greater than 0, 'negative' if the number is less than 0, and 'zero' if the number is 0. Generate all possible test cases.

For further practice, try to create cause-effect graphs and generate test cases for more complex systems.