Chapter 2.4 - Testability Flashcards

1
Q

What is software testing, and how does it differ from debugging?

A

Software testing is the process of finding input values to check against software to reveal failures (mismatch between actual and intended output).

Debugging is the process of finding and fixing a fault in the code after a failure is identified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some challenges in software testing?

A

There are multiple different kinds of system that need to be tested

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are some challenges in Testing GUIs ?

A

dynamic elements, multiple environments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are some challenges in embedded systems ?

A

smartcards, hardware dependencies

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are some challenges in non-deterministic systems?

A

same input may yield different outputs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between software testability and software testing?

A

Software testing assesses software quality by checking correctness against expected results.

Software testability describes how easy it is to design, execute, and analyze tests, which reduces testing effort and costs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are key properties of software that affect testability?

A

Observability – Can we see the internal state of the system?

Controllability – Can we easily set up test conditions?

Isolateability – Can we test components independently?

Complexity/Simplicity – How understandable and modular is the code?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What measures determine how easily a system reveals its faults?

A

Effort required to find faults.

Probability of a fault being revealed.

Time taken to perform tests.

Complexity of test dependencies.

Risk of remaining undetected errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the four conditions necessary for a failure to be revealed in testing?

A

Reachability – The fault must be executed.

Infection – Execution of the fault must corrupt program state.

Propagation – Corrupted state must lead to a visible failure.

Revealability – The test oracle must detect the failure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does Test-Driven Development (TDD) improve software testability?

A

Test-Driven Development (TDD): Write failing tests first, then implement code to pass them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does Design for Testability (DFT) improve software testability?

A

Design for Testability (DFT): Add test interfaces and controlled system states.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does Record & Playback improve software testability?

A

Record & Playback: Capture system states for reproducible testing.

Limiting Complexity: Reduce dependencies and non-determinism.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does Limiting Complexity improve software testability?

A

Limiting Complexity: Reduce dependencies and non-determinism.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can software testability be assessed?

A

Domain/Range Ratio (DRR): The ratio of input values to output values—higher DRR means lower testability.

Mutation Testing: Injecting defects and observing how often they cause failures.

Implicit Losses: When different inputs yield the same output, reducing test effectiveness.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the tradeoffs involved in improving testability?

A

High controllability improves testing but may break encapsulation.

Increased observability helps debugging but may expose security risks.

High modularity simplifies unit testing but may require extensive integration testing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are some techniques to improve software testability?

A

Test-Driven Development (TDD): Write failing tests first, then implement code to pass them.

Design for Testability (DFT): Add test interfaces and controlled system states.

Record & Playback: Capture system states for reproducible testing.

Limiting Complexity: Reduce dependencies and non-determinism.

17
Q

What are the steps of TDD?

A

Write a failing test – Test fails because no code exists.

Make the test pass – Implement the minimal code.

Refactor – Improve code while keeping the test passing.

18
Q

What is the software testing pyramid?

A

Unit Tests (Fast, cheap, most numerous).

Integration Tests (Verify component interactions).

End-to-End Tests (Slowest, most expensive, least frequent).

19
Q

Why do microservices favor integration tests over unit tests?

A

Individual microservices depend on interactions, making unit tests less effective.

Integration tests ensure correct communication between services.

Excessive system-level tests are impractical for large architectures.

20
Q

What is Continuous Integration (CI), and how does it support testing?

A

Developers frequently integrate code into a shared repository.

Automated builds and tests ensure changes don’t break the system.

Helps detect integration errors early.

21
Q

Why should software engineers prioritize testability in software design?

A

Reduces testing effort and cost (Easier to design, execute, and analyze tests).

Increases fault detection (Better observability and controllability).

Speeds up debugging (Faster identification and resolution of defects).

Improves maintainability (Easier refactoring and adaptation to new requirements).

22
Q

How does information hiding impact testability?

A

Encapsulation improves modularity but can limit testability.

Too much information hiding makes it difficult to observe internal state for debugging.

Well-designed APIs provide controlled access for testing while maintaining security.

23
Q

What are implicit and explicit losses in software testability?

A

Implicit Losses:

When many different inputs map to the same output.
Example: Integer division (8/3 = 2, 9/3 = 3) loses information compared to real division.

Explicit Losses:

When internal states are not observable.
Example: A function modifies internal variables but does not expose them externally.
24
Q

How do software requirements affect testability?

A

Clear, detailed specifications improve testability by defining expected behavior.

Ambiguous or incomplete requirements make it harder to define test cases.

Formal specifications (e.g., contracts, pre/post-conditions) improve automated testing.

25
Q

What are some unique challenges in testing embedded systems?

A

Limited observability (No direct access to internal state).

Hardware dependencies (Requires specialized tools to test).

Real-time constraints (Must ensure timing correctness).

State persistence (E.g., smartcards retain state after power loss, affecting reproducibility).

26
Q

What is mutation testing, and how does it assess test quality?

A

Defects (mutations) are deliberately injected into the program.

A strong test suite should detect these changes.

If the test suite fails to catch mutations, it indicates poor fault detection.

Helps measure test coverage quality, not just quantity.

27
Q

How does chaos engineering relate to software testability?

A

Introduces random failures to test system resilience.

Example: Netflix’s Chaos Monkey randomly shuts down services.

Helps identify weaknesses that are difficult to catch with traditional testing.

28
Q

What are the key challenges in testing cloud-based systems?

A

State is managed externally (Difficult to control test conditions).

Distributed nature increases complexity.

Snapshotting & restoring state can help mitigate some challenges.

Network variability makes performance testing unpredictable.

29
Q

What are some ways to measure software testability?

A

Code complexity (Cyclomatic complexity, coupling, cohesion).

Observability (How easily internal states can be inspected).

Controllability (How easily test cases can set up conditions).

Defect detection probability (How likely is a test to find a fault?).

Effort required for test case development (Time & cost).

30
Q

What is the difference between unit and integration testing?

A

Unit Testing:

Tests individual components in isolation.
Faster, more focused, detects low-level bugs.

Integration Testing:

Tests interactions between components.
Catches defects in API communication and data flow.
31
Q

Why is testing non-deterministic software difficult?

A

Same input may produce different outputs due to randomness or concurrency.
Example: A multi-threaded program may behave differently in each run.
Solutions:

Use mocking to control inputs.
Implement deterministic logging for debugging.
Use property-based testing instead of fixed inputs.

32
Q

How does strong encapsulation impact software testability?

A

Pros:
Improves modularity and security.
Reduces unintended side effects.

Cons:
Harder to access internal states for testing.
May require reflection, test hooks, or dependency injection.

33
Q

How does testability differ between OO and functional programming?

A

OO Languages (Java, C#):
Testability depends on class design, dependency injection, and encapsulation.
Dynamic binding can make debugging harder.

Functional Languages (Haskell, Scala, Elixir):
Pure functions improve testability.
Less reliance on shared state reduces side effects.
Higher-order functions allow flexible test scenarios.

34
Q

How does logging improve testability?

A

Provides observability into program execution.
Helps track failures and unexpected behavior.
Useful in non-deterministic systems where reproduction is difficult.
Good logging follows structured formats (JSON, XML) for analysis.

35
Q

What is the difference between black-box and white-box testability?

A

Black-Box Testability:
Tests based on external behavior.
Independent of internal implementation.
Harder to diagnose specific failures.

White-Box Testability:
Tests internal logic (e.g., branch, path, mutation testing).
Requires code access and knowledge.
More effective in identifying edge cases and security flaws.

36
Q

Why is testability difficult in AI/ML systems?

A

Non-determinism (Model outputs vary based on training data).

Lack of clear expected results (Difficult to define a test oracle).

Performance-driven correctness (Evaluated with accuracy metrics, not exact outputs).

Continuous learning (Model changes over time, making regression testing hard).