
Answer-first summary for fast verification
Answer: Define and import unit test functions from a separate Databricks notebook
The correct approach is to use a separate Databricks notebook to define and import unit test functions. This allows the data engineer to run tests without modifying the production notebooks. By using `%run` commands in the test notebook, the production notebooks' functions can be imported and tested using standard Python frameworks like `unittest` or `pytest`. Options B and D involve restructuring code into files or altering production notebooks, which may not be feasible. Option C relates to test data, not the testing framework setup, making it irrelevant to the specific question about executing unit tests.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
How can a Data Engineer execute unit tests using standard Python testing frameworks for functions defined in multiple Databricks notebooks that are currently in production?
A
Define and import unit test functions from a separate Databricks notebook
B
Define and unit test functions using Files in Repos
C
Run unit tests against non-production data that closely mirrors production
D
Define unit tests and functions within the same notebook
No comments yet.