What Is Statement Testing ?

 


Statement Coverage Testing:

Statement coverage checking out is a white container trying out method geared toward ensuring that each one statements in the supply code are performed at the least once at some point of trying out. It presents perception into the thoroughness of checking out through protecting all paths, strains, and statements in the codebase.

Formula:

Statement coverage = (Number of executed statements / Total range of statements in source code) * a hundred

Example 1:

Consider the following code snippet:

Read A

Read B

if A > B

    Print “A is greater than B”

else

    Print “B is extra than A”

endif

Case 1:

A = 7, B = three

Executed statements: 5

Total statements: 7

Statement insurance: 71.00%

Case 2:

A = four, B = eight

Executed statements: 6

Total statements: 7

Statement insurance: 85.20%

Example 2:

print (int a, int b) 

    int sum = a   b;   

    if (sum > zero)   

       print (“Result is positive”)   

   else   

      print (“Result is poor”)   

Case 1:

A = four, B = 8

Executed statements: 6

Total statements: 8

Statement insurance: seventy five.00%

Case 2:

A = four, B = -8

Executed statements: 7

Total statements: 8

Statement insurance: 87.50%

Coverage Scope:

Statement coverage ensures the execution of all possible paths and statements in the codebase, along with loops, arrays, strategies, exceptions, and manage statements. It enables perceive dead code, unused statements, unused branches, and lacking statements.

Purpose:

  • Check the exceptional and validity of the code.
  • Determine the go with the flow of different paths in the application.
  • Validate the anticipated behavior of the source code.
  • Assess the software program's internal coding and infrastructure.

Drawbacks:

  • Cannot affirm false situations.
  • Requires one of a kind input values to cowl all situations.
  • Achieving 100% coverage may additionally necessitate more than one test instances.

Statement coverage testing is instrumental in ensuring the thoroughness and satisfactory of trying out efforts by way of validating the execution of all statements within the source code. However, it's essential to complement it with other testing strategies for complete code validation.

Next Post Previous Post
No Comment
Add Comment
comment url