问题
Azure Functions abstract plenty of dependencies like queue libraries and Azure Tables. So from a Unit Test dependencies mocking perspective, there is less coding effort (and accordingly less maintenance).
Assuming we are developing locally using Visual Studio 2015
- How can I unit test (not interested in integration test) a single Azure Function? Preferably in xUnit, however, any framework would do.
- How can I unit test a function in a .csx file in general?
回答1:
As it stands, it's not really possible to unit test those files. For that reason (and a number of others), we have switched to a different model when developing Functions from Visual Studio, based on .cs and more standard .NET libraries. This makes a lot of things more 'normal' in Visual Studio. See doc for details.
Update: see also Could not load file or assembly System.Net.Http, Version=4.1.1.0 in Unit Test for Azure Functions relating to unit test projects.
来源:https://stackoverflow.com/questions/42513577/unit-testing-azure-functions-and-csx-files