問題文
A team wants to add unit tests to a training notebook that currently contains 400 lines of sequential code. Which change makes unit testing possible?
選択肢
- Add assertions between the cells of the notebook so that the notebook fails fast when an intermediate value is unexpected, and a failing cell stops the run at the point where the value went wrong.
- Reduce the training data to a small sample so that the notebook runs quickly enough to be executed on every commit, so a failure appears in the commit cycle.
- Extract the transformation logic into named functions that take inputs and return outputs, so each function can be called with fixed inputs and checked against expected results, since a test needs a callable unit with a contract.
- Move the notebook into a repository and enable version control, because tests can only run against files that are tracked, and the runner looks there for them.