Monday, November 23, 2020

White Box Testing

White Box Testing

  • White-box testing sometimes called glass-box testing.
  • It is a test-case design philosophy that uses the control structure described as part of the component-level design to derive test cases.
  • Using white-box testing methods, you can derive test cases that
    • (1) Guarantee that all independent paths within a module have been exercised at least once,
    • (2) Exercise all logical decisions on their true and false sides,
    • (3) Execute all loops at their boundaries and within their operational bounds,
    • (4) Exercise internal data structures to ensure their validity.
  • White-box testing is a verification technique software engineers can use to examine if their code works as expected.
  • White box testing is a strategy in which testing is based on:
    • the internal paths,
    • structure, and
    • implementation of the software under test (SUT).
  • White-box testing is also known as structural testing, clear box testing, and glass box testing. 
  • Generally requires detailed programming skills.

White Box Testing Techniques

  • Basis path testing
    • Flow graph notation
    • Cyclomatic complexity
    • Derived test cases
    • Graph metrics
  • Control structure testing
    • Condition testing
    • Data Flow testing
    • Loop testing 

  • Basis path testing
    • Basis path testing is a white-box testing technique
    • The basis path method enables the test-case designer to derive a logical complexity measure of a procedural design and use this measure as a guide for defining a basis set of execution paths
(1) Flow Graph Notation
    • A simple notation for the representation of control flow, called a flow graph (or program graph).
  • The flow graph describes logical control flow using the notation illustrated in Figure.
Flow Graph Notation

(2) Independent Program Path
    • in terms of a flow graph, an independent path must move along at least one edge that has not been traversed before the path is defined.
    • For example, a set of independent paths for the flow graph illustrated in Figure as…
    • Path 1: 1-11
    • Path 2: 1-2-3-4-5-10-1-11
    • Path 3: 1-2-3-6-8-9-10-1-11
    • Path 4: 1-2-3-6-7-9-10-1-11
  • How do you know how many paths to look for? The computation of cyclomatic complexity provides the answer
  • Cyclomatic complexity is a software metric that provides a quantitative measure of the logical complexity of a program..
  • When used in the context of the basis path testing method, the value computed for cyclomatic complexity defines
  • The number of independent paths in the basis set of a program.
  • Provides you with an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at least once.
  • How Is Cyclomatic Complexity Computed?
  • (1) The number of regions of the flow graph corresponds to the cyclomatic complexity.
    • The flow graph has 4 regions
  • (2) V(G) = E – N + 2
    • E : Number of flow graph edges 
    • N : Number of flow graph nodes
    • V(G) = 11 edges – 9 nodes + 2 = 4
  • (3) V(G) = P + 1
    • P : Number of predicate nodes [More than one outcomes]
    • V(G) = 3 predicate nodes + 1 = 4
(3) Deriving Test Cases
  • The basis path testing method can be applied to a procedural design or to source code
  • The following steps can be applied to derive the basis set / Test cases …
    • Using the design or code as a foundation, draw a corresponding flow graph.
    • Determine the cyclomatic complexity of the resultant flow graph.
    • Determine a basis set of linearly independent paths
    • Prepare test cases that will force the execution of each path in the basis set.
(4) Graph Matrices
  • A data structure, called a graph matrix, can be quite useful for developing a software tool that assists in basis path testing.
  • Graph matrix is a square matrix whose size (i.e., number of rows and columns) is equal to the number of nodes on the flow graph.
  • Each row and column corresponds to an identified node, and matrix entries correspond to connections (an edge) between nodes.
  • A simple example of a flow graph and its corresponding graph matrix [Bei90] is shown in Figure…
Graph Matrices

Control Structure testing technique

(1) Condition Testing
  • Condition testing [Tai89] is a test-case design method that exercises the logical conditions contained in a program module. 
  • A simple condition is a Boolean variable or a relational expression.
Condition Testing

    
(2) Control flow testing

Control flow testing

(3) Data Flow Testing
  • Data flow testing is a powerful tool to detect improper use of data values due to coding errors.
  • For example : main() { int x; if (x == 42 ){ ...} }
  • Variables that contain data values have a defined life cycle.
  • They are created, they are used, and they are killed (destroyed) – Scope

Data Flow Testing

(4) Loop Testing
  • Loop testing is a white-box testing technique that focuses exclusively on the validity of loop constructs.
  • Four different classes of loops [Bei90] can be defined:
    • Simple loops,
    • Concatenated loops,
    • Nested loops,
    • Unstructured loops

Loop Testing

White Box Testing Advantage & Disadvantages

  • Advantage
    • The tester can be sure that every path through the software under test has been identified and tested.
    • Find errors on code level.
    • Typically based on a very systematic approach, covering the complete internal module structure
  • Disadvantages
    • (1) The number of execution paths may be so large then they cannot all be tested.
    • (2) The test cases chosen may not detect data sensitivity errors.
      • For example, p=q/r; may execute correctly except when r=0.
    • (3) White box testing assumes the control flow is correct (or very close to correct). Since the tests are based on the existing paths, nonexistent paths cannot be discovered through white box testing.
    • (4) the tester must have the programming skills to understand and evaluate the software under test.

Wednesday, November 18, 2020

Software Testing Fundamentals

Software Testing Fundamentals

  • The goal of testing is to find errors, and a good test is one that has a high probability of finding an error.
  • Therefore, you should design and implement a computer-based system or a product with “testability” in mind.
  • Test Characteristics :
    • A good test has a high probability of finding an error.
    • A good test is not redundant. Testing time and resources are limited. There is no point in conducting a test that has the same purpose as another test. 
    • A good test should be “best of breed”: In a group of tests that have a similar intent, time and resource limitations may mitigate (moderate) toward the execution of only a subset of these tests. 
    • A good test should be neither too simple nor too complex

Internal & External View of Testing

  • External View : (Black box Testing)
    • Knowing the specified function that a product has been designed to perform, test to see if that function is fully operational and error-free.
    • Includes tests that are conducted at the software interface
    • Not concerned with the internal logical structure of the software
  • Internal View (White Box testing)
    • Knowing the internal workings of a product, test that all internal operations are performed according to specifications and all internal components have been exercised
    • Involves tests that concentrate on close examination of procedural detail
    • Logical paths through the software are tested
    • Test cases exercise specific sets of conditions and loops

White-Box Testing

White-Box Testing


Debugging

 Debugging

  • Debugging occurs as a consequence of successful testing.
  • When a test case uncovers an error, debugging is the process that results in the removal of the error.
  • Although debugging can and should be an orderly process.

Debugging: A Diagnostic Process

Debugging A Diagnostic Process

The Debugging Process


The Debugging Process




Tuesday, November 17, 2020

System Testing & its types

System Testing & its types

  • System testing is actually a series of different tests whose primary purpose is to fully exercise the computer-based system.
  • Although each test has a different purpose, all work to verify that system elements have been properly integrated and perform allocated functions.
  • Types of system tests :
    • Recovery Testing
    • Security Testing
    • Stress Testing
    • Performance Testing
    • Deployment Testing
High Order Testing
  • Validation testing
    • Focus is on software requirements
  • System testing
    • Focus is on system integration
  • Alpha/Beta testing 
    • Focus is on customer usage
  • Recovery testing
    • forces the software to fail in a variety of ways and verifies that recovery is properly performed
  • Security testing
    • verifies that protection mechanisms built into a system will, in fact, protect it from improper penetration
  • Stress testing
    • executes a system in a manner that demands resources in abnormal quantity, frequency, or volume
  • Performance Testing
    • test the run-time performance of software within the context of an integrated system

In Brief;
  • Recovery Testing
    • Recovery testing is a system test that forces the software to fail in a variety of ways and verifies that recovery is properly performed.
    • If recovery is automatic (performed by the system itself), reinitialization, checkpointing mechanisms, data recovery, and restart are evaluated for correctness.
    • If recovery requires human intervention, the mean-time-torepair (MTTR) is evaluated to determine whether it is within acceptable limits
  • Security Testing
    • Security testing attempts to verify that protection mechanisms built into a system.
  • Stress Testing
    • It executes a system in a manner that demands resources in abnormal quantity, frequency, or volume.
    • Stress tests are designed to face programs with abnormal situations. In essence, the tester who performs stress testing asks: "How high can we crank this up before it fails?"
    • variation of stress testing is a technique called sensitivity testing.
  • Performance Testing
    • Test the run-time performance of software within the context of an integrated system.
    • Performance tests are often coupled with stress testing.
    • Performance testing occurs throughout all steps in the testing process. Even at the unit level, the performance of an individual module may be assessed as tests are conducted
  • Deployment Testing
    • In many cases, software must execute on a variety of platforms and under more than one operating system environment.
    • Deployment testing, sometimes called configuration testing, exercises the software in each environment in which it is to operate.
    • In addition, deployment testing examines all installation procedures and specialized installation software (e.g., “installers”) that will be used by customers, and all documentation that will be used to introduce the software to end users.