496
GB
What is 'design for testability' and what structural properties does it require?
IN
'परीक्षण योग्यता के लिए डिज़ाइन' क्या है और इसके लिए किन संरचनात्मक गुणों की आवश्यकता है?
A
Design for testability means writing tests before writing production code (TDD)
परीक्षण योग्यता के लिए डिज़ाइन का अर्थ है उत्पादन कोड (टीडीडी) लिखने से पहले परीक्षण लिखना
B
Design for testability structures software so components can be isolated and tested independently — requiring: well-defined interfaces, dependency injection, avoidance of global state, separation of I/O from logic, and observable internal state
परीक्षण योग्यता संरचना सॉफ़्टवेयर के लिए डिज़ाइन ताकि घटकों को अलग किया जा सके और स्वतंत्र रूप से परीक्षण किया जा सके - आवश्यकता है: अच्छी तरह से परिभाषित इंटरफेस, निर्भरता इंजेक्शन, वैश्विक स्थिति से बचाव, तर्क से I/O को अलग करना, और अवलोकन योग्य आंतरिक स्थिति
C
Design for testability only applies to safety-critical systems that require formal verification
परीक्षण योग्यता के लिए डिज़ाइन केवल सुरक्षा-महत्वपूर्ण प्रणालियों पर लागू होता है जिन्हें औपचारिक सत्यापन की आवश्यकता होती है
D
Design for testability requires that all code branches be executable with a single test case
परीक्षण योग्यता के लिए डिज़ाइन के लिए आवश्यक है कि सभी कोड शाखाएँ एक ही परीक्षण केस के साथ निष्पादन योग्य हों
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English)
A class with hardcoded database connections cannot be unit-tested without a real database. Design for testability explicitly considers how code will be tested during design: constructor injection enables mock dependencies; pure functions (no side effects) are trivially testable; separating HTTP parsing from business logic allows testing business logic without HTTP; observable state (not just through effects) enables state verification.
व्याख्या (हिन्दी)
हार्डकोडेड डेटाबेस कनेक्शन वाले वर्ग को वास्तविक डेटाबेस के बिना यूनिट-परीक्षण नहीं किया जा सकता है। परीक्षण योग्यता के लिए डिज़ाइन स्पष्ट रूप से इस बात पर विचार करता है कि डिज़ाइन के दौरान कोड का परीक्षण कैसे किया जाएगा: कंस्ट्रक्टर इंजेक्शन नकली निर्भरता को सक्षम बनाता है; शुद्ध कार्य (कोई दुष्प्रभाव नहीं) तुच्छ परीक्षण योग्य हैं; HTTP पार्सिंग को व्यावसायिक तर्क से अलग करने से HTTP के बिना व्यावसायिक तर्क का परीक्षण करने की अनुमति मिलती है; अवलोकन योग्य स्थिति (केवल प्रभावों के माध्यम से नहीं) राज्य सत्यापन को सक्षम बनाती है।