Algorithms Quality Control & Assurance 5 β Questions and Answers
Question 1: What is the 'test pyramid' model's recommendation regarding unit tests?
- Unit tests should be fewest because they are slowest
- Unit tests should form the largest base because they are fast and cheap (Correct answer)
- Unit tests and UI tests should be equally numerous
- Unit tests should only cover edge cases
Correct answer: Unit tests should form the largest base because they are fast and cheap
The test pyramid advocates for a large base of fast, cheap unit tests, fewer integration tests, and the fewest end-to-end tests to keep the suite efficient.
Question 2: What does 'defensive programming' contribute to algorithm quality assurance?
- It encrypts all algorithm outputs
- It adds input validation and assertions to prevent incorrect states from propagating (Correct answer)
- It reduces the number of tests needed
- It speeds up code execution by removing checks
Correct answer: It adds input validation and assertions to prevent incorrect states from propagating
Defensive programming anticipates invalid inputs and unexpected states, adding checks that catch problems close to their source rather than far downstream.
Question 3: Which approach in quality assurance involves injecting deliberate failures to test a system's resilience?
- Unit testing
- Chaos engineering (Correct answer)
- Static analysis
- Test-driven development
Correct answer: Chaos engineering
Chaos engineering deliberately introduces failures (killing nodes, adding latency) in controlled environments to verify that a system degrades gracefully.
Question 4: In algorithm QA, what is a 'golden master' (snapshot) test used for?
- Benchmarking against a competitor's algorithm
- Comparing current output to a previously approved reference output (Correct answer)
- Verifying cryptographic correctness
- Checking regulatory compliance
Correct answer: Comparing current output to a previously approved reference output
A golden master test stores a known-good output and flags any deviation, useful when the correct result is complex but stable.
Question 5: What is the purpose of 'contract testing' between algorithm microservices?
- To enforce licensing agreements automatically
- To verify that a provider's API matches the expectations of its consumers (Correct answer)
- To measure inter-service latency
- To count the number of API calls made
Correct answer: To verify that a provider's API matches the expectations of its consumers
Contract testing ensures that the interface a service provides matches what its consumers depend on, catching integration breaks without full end-to-end tests.
Question 6: Which metric captures the percentage of known defects detected by a test suite before release?
- Code coverage
- Defect detection percentage (DDP) (Correct answer)
- Mean time to repair (MTTR)
- Cyclomatic complexity
Correct answer: Defect detection percentage (DDP)
Defect detection percentage measures how many pre-release bugs the test suite finds versus the total found (pre + post release), indicating test effectiveness.
Question 7: What is 'shift-left testing' in the context of algorithm development?
- Moving tests from unit level to system level
- Performing testing activities earlier in the development lifecycle (Correct answer)
- Shifting test responsibility to end users
- Running tests only after deployment
Correct answer: Performing testing activities earlier in the development lifecycle
Shift-left testing moves QA activities toward the start of development so defects are found and fixed when they are cheapest to address.
What is the 'test pyramid' model's recommendation regarding unit tests?