CAD Testing & Debugging 1 — Questions and Answers
Question 1: What type of testing verifies that individual components or functions work correctly in isolation?
- Integration testing
- Unit testing (Correct answer)
- System testing
- Acceptance testing
Correct answer: Unit testing
Unit testing focuses on testing individual components or functions in isolation to verify each piece works correctly on its own.
Question 2: Which debugging technique involves adding output statements to track program flow and variable values?
- Remote debugging
- Breakpoint debugging
- Print/log debugging (Correct answer)
- Memory profiling
Correct answer: Print/log debugging
Print/log debugging inserts output statements to display variable values and execution flow without requiring specialized tooling.
Question 3: What is the purpose of a regression test?
- To check for performance degradation
- To verify previously working functionality still works after code changes (Correct answer)
- To validate backward compatibility with older systems
- To measure database query efficiency
Correct answer: To verify previously working functionality still works after code changes
Regression tests confirm that recent code changes have not broken functionality that was previously working correctly.
Question 4: In test-driven development (TDD), what is the correct order of steps?
- Write code → Write test → Refactor
- Write test → Write code → Refactor (Correct answer)
- Refactor → Write test → Write code
- Write code → Refactor → Write test
Correct answer: Write test → Write code → Refactor
TDD follows the Red-Green-Refactor cycle: write a failing test first, write minimal code to pass it, then refactor for quality.
Question 5: What does 'code coverage' measure in a software testing context?
- The number of tests written per developer
- The percentage of source code executed during testing (Correct answer)
- The time required to run the full test suite
- The number of defects found per test case
Correct answer: The percentage of source code executed during testing
Code coverage measures what percentage of the source code is actually executed when the test suite runs, indicating how thoroughly the code is tested.
Question 6: Which type of testing is performed without knowledge of the internal code structure?
- White-box testing
- Gray-box testing
- Black-box testing (Correct answer)
- Glass-box testing
Correct answer: Black-box testing
Black-box testing evaluates application functionality based solely on inputs and outputs, without any knowledge of internal implementation.
Question 7: What is a 'mock object' in the context of unit testing?
- A real dependency used in a controlled environment
- A simplified version of the application under test
- A simulated object that mimics the behavior of real dependencies (Correct answer)
- A test environment that mirrors production exactly
Correct answer: A simulated object that mimics the behavior of real dependencies
A mock object simulates the behavior of real dependencies such as databases or APIs, allowing unit tests to run in complete isolation.
What type of testing verifies that individual components or functions work correctly in isolation?