10.05 Unit Tests Subsystems - Quiz¶
Section 10.5 Quiz: Unit Tests for Subsystems
-
What is the main purpose of test fixtures in mechatronic testing?
- To hold physical components in place
- To provide controlled substitutes for hardware components {data-correct}
- To measure electrical current
- To calibrate sensors
-
Which testing principle ensures that tests produce the same results every time they run?
- Isolation
- Repeatability {data-correct}
- Fast execution
- Clear assertions
-
What is dependency injection in the context of testable system design?
- Injecting power into system components
- Providing system dependencies through constructor parameters {data-correct}
- Adding test code directly into production classes
- Connecting hardware components physically
-
Mock devices in unit testing should:
- Be identical to real hardware
- Provide predictable, controllable behaviour {data-correct}
- Always return the same values
- Only work with simple systems
-
When testing a temperature controller, which scenarios should be included in comprehensive tests?
- Normal operation within target range {data-correct}
- Safety limit enforcement {data-correct}
- Sensor failure handling {data-correct}
- Only successful temperature control
-
What is the advantage of testing control logic separately from hardware interfaces?
- Tests run faster without hardware delays {data-correct}
- Hardware failures don’t affect test results {data-correct}
- Tests can run without expensive equipment {data-correct}
- Tests become more complex
-
Integration tests with multiple fixtures are useful for:
- Testing individual components in isolation
- Verifying subsystem interactions work correctly {data-correct}
- Replacing all unit tests
- Testing only hardware components
-
A well-designed mock sensor should be able to:
- Simulate various failure modes {data-correct}
- Provide controlled test data {data-correct}
- Add realistic noise to readings {data-correct}
- Only return perfect measurements