单元测试Azure函数和.csx文件 [英] Unit Testing Azure Functions and .csx Files

查看:76
本文介绍了单元测试Azure函数和.csx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure函数抽象了很多依赖项,例如队列库和Azure表.因此,从单元测试依赖关系模拟的角度来看,可以减少编码工作量(并因此减少维护).

假设我们正在使用Visual Studio 2015进行本地开发

  • 如何对单个Azure函数进行单元测试(对集成测试不感兴趣)?但是,最好在xUnit中,任何框架都可以.
  • 一般如何在.csx文件中对功能进行单元测试?

解决方案

就目前而言,不可能对这些文件进行单元测试.出于这个原因(以及许多其他原因),当从Visual Studio开发基于.cs和更多标准.NET库的Function时,我们已切换到其他模型.这使很多东西在Visual Studio中变得更加正常".有关详细信息,请参见文档.

>

更新:另请参见 解决方案

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.

这篇关于单元测试Azure函数和.csx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆