問題文
A cheese maker's ripening calculator asks a helper class for today's date, and a reviewer objects to the line that checks whether a test is currently running and returns a fixed date when it is. Which change follows the documented approach?
選択肢
- Keep the branch but move it into the helper class, because the calculator then has no knowledge of the test and only the helper needs to be reviewed, so the reviewer looks at one file.
- Annotate the helper's method so it is visible to tests and assign the fixed date to it from the test class, because a member marked as visible to tests can be written from outside its own class without changing the production signature.
- Have the calculator receive the helper as a parameter so the test can pass a stub built at runtime, which is what the platform's stubbing feature is designed for.
- Make the helper's method static so that the test can override it, because static members are resolved at compile time in either build.