Statement Coverage - Georgia Tech - Software Development Process

Udacity
23 Feb 201503:42

Summary

TLDRThe video script discusses the concept of statement coverage in white-box testing, emphasizing its simplicity and importance in software testing. It explains that statement coverage requires executing all statements in the program to identify faults. The script illustrates this with a 'printSum' example, showing how different test cases lead to varying degrees of coverage, from 71% to 100%. It also mentions that while 100% coverage is achievable, companies often aim for 80-90% due to practical constraints, sparking curiosity about the reasons behind this approach.

Takeaways

  • 📝 Statement Coverage is the simplest form of white-box testing, focusing on executing all statements in the program.
  • 🔍 Test requirements for statement coverage involve ensuring that each statement in the code is executed at least once.
  • 📊 Measuring statement coverage is done by calculating the ratio of executed statements to the total number of statements.
  • 🎯 The goal of statement coverage is to exercise the code to find faults, aiming for a high ratio of executed statements.
  • đŸ€” The script raises the question of why not aim for 100% statement coverage, highlighting a common industry practice.
  • 📈 In practice, companies often target a statement coverage of 80-90%, which is considered a balance between thoroughness and practicality.
  • 📋 The script uses a 'printSum' example to demonstrate how statement coverage is measured and improved through different test cases.
  • 📊 The progress bar in the example visually represents the percentage of code coverage achieved, aiming for full coverage.
  • 🔧 The example shows that by running different test cases, it's possible to achieve 100% statement coverage, demonstrating the effectiveness of the approach.
  • đŸ› ïž Statement coverage is the most commonly used coverage criterion in the industry, indicating its importance in software testing.

Q & A

  • What is statement coverage in white-box testing?

    -Statement coverage is a white-box testing criterion that requires all statements in the program to be executed. It is characterized by the test requirements for the criteria and how coverage is measured, which is the ratio of the number of executed statements to the total number of statements in the program.

  • Why is statement coverage considered the simplest coverage criterion in white-box testing?

    -Statement coverage is considered the simplest because it only requires that every statement in the code be executed at least once, without considering the conditions under which they are executed.

  • What is the assumption behind white-box testing according to the script?

    -The assumption behind white-box testing is that if there isn't a faulty element in the code, it needs to be exercised (executed) to find the fault.

  • How is the effectiveness of statement coverage measured?

    -The effectiveness of statement coverage is measured by the ratio of the number of executed statements to the total number of statements in the program. A higher ratio indicates better code exercise.

  • What question is asked when assessing statement coverage?

    -When assessing statement coverage, the question asked is whether each statement in the program has been executed.

  • What is the goal of statement coverage in terms of percentage?

    -The goal of statement coverage is to achieve 100%, meaning all statements in the program have been executed.

  • What are the typical coverage targets for statement coverage in the industry?

    -In the industry, the typical coverage targets for statement coverage are 80-90%, meaning the tests should exercise 80-90% of the statements by the end of testing.

  • Why might a company not aim for 100% statement coverage?

    -A company might not aim for 100% statement coverage because it can be resource-intensive and sometimes impractical to achieve, or because certain code paths may be deemed unreachable or unnecessary for the software's intended use.

  • How does the script illustrate the measurement of statement coverage with the 'printSum' example?

    -The script uses the 'printSum' example to illustrate statement coverage by showing the execution of statements with different test cases and highlighting the parts of the code covered. It demonstrates how the coverage percentage is calculated and how it can reach 100%.

  • What happens when the 'printSum' example is tested with inputs a=3 and b=9?

    -When the 'printSum' example is tested with inputs a=3 and b=9, the test case covers five out of seven statements, resulting in approximately 71% coverage.

  • How does the second test case for 'printSum' affect the statement coverage?

    -The second test case for 'printSum', with inputs a=-5 and b=-8, causes the if condition to evaluate to false, executing the else part, thus covering all statements and achieving 100% statement coverage.

Outlines

plate

Cette section est réservée aux utilisateurs payants. Améliorez votre compte pour accéder à cette section.

Améliorer maintenant

Mindmap

plate

Cette section est réservée aux utilisateurs payants. Améliorez votre compte pour accéder à cette section.

Améliorer maintenant

Keywords

plate

Cette section est réservée aux utilisateurs payants. Améliorez votre compte pour accéder à cette section.

Améliorer maintenant

Highlights

plate

Cette section est réservée aux utilisateurs payants. Améliorez votre compte pour accéder à cette section.

Améliorer maintenant

Transcripts

plate

Cette section est réservée aux utilisateurs payants. Améliorez votre compte pour accéder à cette section.

Améliorer maintenant
Rate This
★
★
★
★
★

5.0 / 5 (0 votes)

Étiquettes Connexes
White-Box TestingStatement CoverageTest RequirementsCode ExecutionCoverage MeasurementSoftware TestingQuality AssuranceTest CasesCode AnalysisIndustry Practice
Besoin d'un résumé en anglais ?