3. Testing Flashcards
(37 cards)
What is software testing?
Software testing is the process of evaluating a software solution to ensure that it behaves as expected and meets the specified requirements. It involves executing the software under controlled conditions and assessing its behavior to identify any defects or bugs.
What is a “bug” or “fault” in software?
A fault, also called a bug or a defect, is an erroneous software or hardware element of a system that can cause the system to fail.
List three primary reasons why we test software.
Finding defects: To identify errors in functionality, performance issues, or UI inconsistencies.
Ensuring quality: To ensure the software meets quality standards and fulfills specified requirements, aiming for a reliable and robust product.
Validating requirements: To verify the software behaves according to specified requirements.
(Additionally) Improving user experience: To make the software more user-friendly and satisfying by fixing defects.
What important limitation of testing did Edsger W. Dijkstra highlight?
“Testing shows the presence, not the absence, of bugs”. This means we can never be 100% sure software is bug-free, but proper testing methodology helps get close.
What is Test-Driven Development (TDD)?
TDD is a software development approach where tests are written before the actual implementation code.
What are the core principles of TDD?
- Every development step must start with a plan to verify that the result meets a goal.
- A developer should not create a software artifact (requirement, diagram, code) unless they know how it will be tested.
Describe the “Red-Green-Refactor” cycle in TDD.
Red: Write a failing test case for desired behavior before implementation. The test fails because no code exists yet.
Green: Write the minimal amount of code necessary to make the failing test pass.
Refactor: After the test passes, improve the code’s design, readability, and maintainability while ensuring all tests continue to pass.
List two benefits of Test-Driven Development (TDD).
Improved code quality: Encourages modular, well-designed code.
Reduced bugs: Catching bugs early by writing tests upfront.
Faster feedback loop: Provides rapid feedback on code behavior.
Better documentation: Tests serve as executable documentation.
Define “White-box testing.”
White-box testing exploits the internal structure, design, and code of a system; the internal workings are transparent to the tester.
Define “Black-box testing.”
Black-box testing explores the input space of functionality defined by an interface specification, testing from an end-user perspective where internal workings are hidden.
Why is it generally impossible to completely test any non-trivial system?
Because the number of possible inputs, states, and paths can be astronomically large, making exhaustive testing impractical. For example, testing all 4-digit keycodes, plus incomplete codes, and sequences of codes
What is the primary goal of testing, considering its difficulty and cost?
To find faults as cheaply and quickly as possible. The underlying idea is that correct behavior on “critical” test cases represents correct behavior on untested parts.
What is “coverage” in software testing?
Coverage measures the degree to which the specification or code of a software program has been exercised by tests.
Differentiate between “Test Coverage” (Specification testing) and “Code Coverage.”
Test Coverage (Big picture/Specification testing): Focuses on the coverage of the input space, often without testing every part of the software (e.g., acceptance tests).
Code Coverage (Implementation details): Measures the degree to which elements of the program source code have been tested (e.g., unit tests).
What is Equivalence Testing?
A black-box testing method that divides the input space into equivalence groups/classes where the program is expected to behave the same for each input from the same group.
What are the two main steps in Equivalence Testing?
Partition the input values into equivalence classes.
Test one or more inputs from each equivalence class.
What is Boundary Testing (or Boundary Value Analysis)?
A special case of equivalence testing that focuses on the boundary values (edges, outliers like min/max, zero, empty strings) of input parameters, based on the assumption that developers often overlook these special cases.
What is Control-Flow Testing?
A white-box testing technique that organizes testing based on the control flow of the software, often using a control flow graph where statements are nodes and transitions are edges.
List three types of code coverage measures in Control-Flow Testing.
- Statement coverage
- Edge coverage
- Condition coverage
- Path coverage.
Does 100% statement coverage imply 100% edge coverage? Explain briefly.
No. For example, in if condition: do_something(), if condition is always true, do_something() is always executed (100% statement coverage), but the path where condition is false (and do_something() is skipped) is never tested, leading to incomplete edge coverage.
What is State-Based Testing?
It defines a set of abstract states a software unit can take and tests its behavior by comparing actual states to expected states. It’s popular with object-oriented systems.
Name three components involved in State-Based Testing.
- State (constraint on attribute values),
- Event (input), Action (result/output)
- Transition (change of state),
- Guard (condition for transition).
List two common control faults in State-Based Testing.
Missing transition, incorrect transition, inconsistent state transition, looping/infinite state transition, missing/incorrect action, incorrect state handling, sneak path, trap door, deadlocks, or livelocks.
What is Unit Testing?
Testing the smallest possible part of a system, called a unit (or fixture), individually and independently.