Visual Studio Online中的数据库集成测试 [英] Database integration tests in Visual Studio Online

查看:59
本文介绍了Visual Studio Online中的数据库集成测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很喜欢Visual Studio Online中的新构建工具.允许我执行本地构建服务器的几乎所有操作.但是我缺少的一件事是集成数据库测试:对于每一次构建运行,我都会从脚本中重新创建测试数据库,并对它运行数据库测试.

I'm enjoying the new Build tool in Visual Studio Online. Allows me to do almost everything that I do my local build server. But one thing that I'm missing is integration database tests: for every build run I re-create test database from scripts and run DB-tests against it.

在Visual Studio Online中,我似乎找不到满足我需要的任何数据库实例.

In Visual Studio Online I can't seem to find any database instance available for my needs.

我尝试为每次构建运行创建Azure SQL数据库(通过PowerShell),然后在构建完成后将其删除.但是创建数据库需要花费很多时间(与构建过程的其余部分相比).即使完成了PowerShell脚本,数据库仍未准备好接受请求-我需要不断检查它是否真的准备好了.因此,这种情况变得太复杂且不可靠.

I have tried creating Azure SQL database (via PowerShell) for every build run and then delete it after the build is complete. But it takes forever (comparing to the rest of the build process) to create a database. And even when PowerShell scripts are done, database is not yet ready to accept requests - I need to constantly check if it is actually ready. So this scenario becomes too complex and not reliable.

在Visual Studio Online中还有其他选项可以进行数据库(SQL Server)集成测试吗?

Are there other options to do database (SQL Server) integration tests in Visual Studio Online?

更新:我想我不太清楚我需要什么-我需要一个免费的(非常便宜的)SQL Server实例来连接到VSO中在构建代理上运行的实例.诸如SQL Express或SQL CE或LocalDB之类的东西,我可以在其中连接并重新创建数据库以对其运行C#测试.重新创建数据库或运行测试不是问题,拥有有效的连接字符串是一个问题.

Update: I think I'm not very clear of what I need - I need a free (very cheap) SQL Server instance to connect to that runs on build agent in VSO. Something like SQL Express or SQL CE or LocalDB, where I can connect to and re-create database to run C# tests against. Re-creating database or running tests is not a problem, having a valid connection string is a problem.

2016年10月更新:

Update Oct 2016: I've blogged about how I do integration testing in VSTS

推荐答案

TFS构建服务器预装有MSSQL Server 2012和MSSQL Server 2014 LocalDB.

The TFS build servers come with MSSQL Server 2012 and MSSQL Server 2014 LocalDBs preinstalled.

来源: TFS服务-托管构建服务器上的软件

因此,只需将以下代码添加到解决方案的构建后事件中,即可创建满足您需求的 MYTESTDB LocalDB实例.这将允许您连接到(LocalDB)\MYTESTDB并运行数据库集成测试就可以了.

So, just put the following one-liner into your solution's post-build event to create a MYTESTDB LocalDB instance for your needs. This will allow you to connect to (LocalDB)\MYTESTDB an run the database integration tests just fine.

"C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "MYTESTDB" 12.0 -s

来源: SqlLocalDB实用程序

这篇关于Visual Studio Online中的数据库集成测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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