200-901 · Question #141
FILL BLANK Fill in the blanks to complete the Bash script in which each file in a directory is renamed to its SHA256 hash? TARGET_DIR=/usr/local/certs for f in '__________ __________'; do __________…
The correct answer is C. write and run tests before writing new code. The question stem describes a bash scripting scenario but the answer choices pertain to test-driven development (TDD). Based on the choices and correct answer provided, the question tests knowledge of the TDD methodology.
Question
FILL BLANK Fill in the blanks to complete the Bash script in which each file in a directory is renamed to its SHA256 hash? TARGET_DIR=/usr/local/certs for f in '__________ __________'; do __________ $f' openssl sha -sha256 -r < $f | cut -f1 -cl' '' Answer:
TARGET_DIR=/usr/local/certs for f in '/usr/local/certs'; do echo $f' openssl sha -sha256 -r < $f | cut -f1 -cl' ''
Options
- Awrite documentation for tests
- Bwrite tests after adding new blocks of code
- Cwrite and run tests before writing new code
- Drun tests after writing new code
How the community answered
(55 responses)- A2% (1)
- B11% (6)
- C84% (46)
- D4% (2)
Why each option
The question stem describes a bash scripting scenario but the answer choices pertain to test-driven development (TDD). Based on the choices and correct answer provided, the question tests knowledge of the TDD methodology.
Writing documentation for tests is a documentation practice and is not a defining principle of TDD.
Writing tests after adding code describes the traditional 'test-last' approach, which is the opposite of TDD.
Test-driven development requires that tests be written and run before any production code is authored. This 'Red-Green-Refactor' cycle - write a failing test, write code to pass it, then refactor - is the defining tenet of TDD and ensures all code has a corresponding test driving its implementation.
Running tests after writing code does not conform to TDD, which requires tests to exist and fail before any new production code is written.
Concept tested: Test-driven development core tenet
Source: https://martinfowler.com/bliki/TestDrivenDevelopment.html
Topics
Community Discussion
No community discussion yet for this question.