Unit Testing Azure Functions and .csx Files

故事扮演 提交于 2019-12-09 12:24:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!