Data Factory - Testing Framework :hammer_and_wrench:
A stand-alone test framework that allows to write unit tests for Data Factory pipelines on Microsoft Fabric, Azure Data Factory and Azure Synapse Analytics.
The framework is currently in Public Preview and is not officially supported by Microsoft.
Features :star:
The framework evaluates pipeline and activity definitions which can be asserted. It does so by providing the following features:
- Evaluate expressions by using the framework's internal expression parser. It supports all the functions and arguments that are available in the Data Factory expression language.
- Test an activity with a specific state and assert the evaluated expressions.
- Test a pipeline run by verifying the execution flow of activities for specific input parameters and assert the evaluated expressions of each activity.
The framework does not support running the actual pipeline. It only gives you the ability to test the pipeline and activity definitions.
High-level example :bulb:
Given a WebActivity
with a typeProperties.url
property containing the following expression:
@concat(pipeline().globalParameters.BaseUrl, variables('Path'))
A simple test to validate that the concatenation is working as expected could look like this:
activity = pipeline.get_activity_by_name("webactivity_name")
state = PipelineRunState(
parameters=[
RunParameter(RunParameterType.Global, "BaseUrl", "https://example.com"),
],
variables=[
PipelineRunVariable("Path", "some-path"),
])
activity.evaluate(state)
assert "https://example.com/some-path" == activity.type_properties["url"].result
Why :question:
Data Factory does not support unit testing, nor testing of pipelines locally. Having integration and e2e tests running on an actual Data Factory instance is great, but having unit tests on top of them provides additional means of quick iteration, validation and regression testing. Unit testing with the Data Factory Testing Framework has the following benefits:
- Runs locally with immediate feedback
- Easier to cover a lot of different scenarios and edge cases
- Regression testing
Getting started :rocket:
Before you start writing tests, you need to set up the repository and install the framework:
- Repository setup
- Installing and initializing the framework
If you are not that experienced with Python and prefer a step-by-step guide, use the more detailed getting started guide.
The framework allows you to write two types of tests:
Concepts :books:
The following pages go deeper into different topics and concepts of the framework to help in getting you started.
Basic :seedling:
- Repository setup
- Installing and initializing the framework
- State
- Activity testing
- Pipeline testing
Advanced :microscope:
- Debugging your activities and pipelines
- Development workflow
- Overriding expression functions
- Framework internals
Examples :memo:
More advanced examples demonstrating the capabilities of the framework:
Fabric:
- Batch job example
Azure Data Factory:
- Copy blobs example
- Batch job example
Azure Synapse Analytics:
- Copy blobs example
Contributing :handshake:
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct.
For more information see the Code of Conduct FAQ or
contact opencode@microsoft.com with any additional questions or comments.
Trademarks :tm:
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
Microsoft's Trademark & Brand Guidelines.
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.