How do I install a SQL Server on the hosted build agent in Visual Studio Online?

。_饼干妹妹 提交于 2019-12-08 11:14:44

问题


One of our customers uses Visual Studio Online ( http://www.visualstudio.com/en-us/products/what-is-visual-studio-online-vs.aspx ) which is based on capabilities of Team Foundation Server (TFS)

We were researching how to do automated Builds and automated Unit Tests using the Visual Studio Online account.

Using Visual Studio 2012 IDE, I was able to setup a build in the Hosted Build Service. However, my Unit Tests need a Microsoft SQL Server Database to run properly, which I have installed on my development workstation.

In order to run my tests I need to have my database running in a SQL instance on the build agent.

Is it possible to install SQL server on the Hosted Build Agent, and if so, how?


回答1:


It is not possible to add non-standard capabilities to a hosted build agent. You are assigned a clean pre-built VM with all of the standard pre-requisite for compiling binaries and running unit tests. As integration tests, what you are describing above, require an instance of your application you can't run them there.

Here are the options that you have in order of recommendation:

1 - Re-write your tests as Unit and not Integration

The tests that you are describing above do not meet the standard definition of "Unit Test". You can use mocking, stubs, and other testing techniques to decouple your tests from the database so that they are only testing a single unit of functionality rather than the integration between your code and the database. Having sets of tests for each will better help you isolate the route cause of the issue and more quickly fix it at less cost to your customer. It will also aid in the reduction of bugs and other issues that can be introduced over time.

Large complicated integration tests should be kept to a minimum as it increases the amount of time required to support them and maximises the cost to your customer.

One obviously needs integration tests at some point and option #2 is the best for running integrations.

2 - Use Release Management to deploy and test

You can setup a VM to host a working version of your application and use Release Management to deploy the instance then execute your Integration Tests there. If you use the VSO hosted Release Management server you are limited to Azure VM's as targets. If you deploy your own RM server then you need to manage that as well. I would and do use the hosted RM.

The bit we care about is the DevOps bit on the right. Any time you need an instance of your application it should be deployed correctly separately from your build server.

http://nakedalm.com/create-release-management-pipeline-professional-developers/

Once you have your application deployed it is fairly simple to get the integration tests you want executing against the instance.

http://blogs.msdn.com/b/visualstudioalm/archive/2014/11/11/deploying-and-testing-web-applications-using-release-management.aspx

If you download the example from the link above it has a powershell for executing the tests in the environment.

3 - Setup your own agent and controller

You can create your own build controller & agent attached to the VSO account and build the app yourself. Most folks create an Azure VM with all of the bits they need and run there. This is your server that you will need to manage and pay for. You can also use a local server.

Note: This is the wrong approach as an instance of your application should not be available on a build server. A build server is for compiling your binaries and running actual Unit Tests, not integration or UI tests.




回答2:


Thanks for all your help.

I contacted @tamasf who is one of the developers for the Effort Testing Tool for Entity Framework, and he told me that Effort Testing Tool only needs to know about he EDMX file in order mock Entity Framework ( which means Database won't need to be up and running, therefore, allowing us to follow proper Unit testing practices ) For more information, please read the following post: How would I configure Effort Testing Tool to mock Entity Framework's DbContext withOut the actual SQL Server Database up and running?



来源:https://stackoverflow.com/questions/27705432/how-do-i-install-a-sql-server-on-the-hosted-build-agent-in-visual-studio-online

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