- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 02:33 AM
@Fuad Goloba :
When running tests on Databricks, you need to ensure that the test file is uploaded to the Databricks workspace and that the correct path is specified when importing the test module in the notebook that is running the tests. Here's an example of how you could modify your run_unit_tests notebook to run the tests from test_transforms.py on Databricks:
# Import the required modules
import unittest
import os
# Set the path to the directory containing the test file
test_dir = '/path/to/test/files/'
# Add the test directory to the Python path
os.sys.path.append(test_dir)
# Import the test module
import test_transforms
# Run the tests
run_test = unittest.main(argv=[' '], verbosity=2, exit=False)
# Check if the tests were successful
assert run_test.result.wasSuccessful(), 'Test failed; see logs above'Make sure to replace /path/to/test/files/ with the actual path to the directory containing your test file. You can check the path using the dbutils.fs.ls() function. Once you have verified that the tests are running correctly on Databricks, you can set up a GitHub action to trigger the tests as part of your continuous integration process. In the action, you can use the Databricks CLI to upload the test file to the workspace and run the tests on Databricks.