It is a Windows Service running with configurable identity so changing it is simple. In my case it has the same name than my machine name and it is running under NT AUTHORITY \ NETWORK SERVICE. Your tests will always be run by the controller. But you probably either don’t want to user SQL Server users (remember those best practices) and you definitely don’t want to have its password in clear text in the app.config of your project!! Using integrated security with unit tests If you use a SQL Server user like I do in my example, its password will not be saved and you will end having to edit the app.config file of the test project to add the user password. I probably don’t want to give access to the continuous integration database to machine user. If you use integrated authentication in your execution context it will use the identity of the user running the build controller, in my case it is my machine name on the domain. Which in our case is not necessary since we are already doing that as part of a continuous integration project.ġ is the Execution context and 2 if you specify it will be the Privileged Context (for running pre or post build scripts and/or deploying the database before running the tests). You will see a dialog where you can specify or create a connection to a database and a few other options, like deploying the database before you run the test. To modify context permissions you need to right click on your test project and choose SQL Server Test configuration: Where the privileged context connection requires more permissions due to the tasks performed. Run TestInitialize and TestCleanup scriptsĭeploy database changes before you run testsĪs you can see there are two types of context database connection: Execution Context and Privileged Context. You must have the following permissions to perform unit tests on a database: Action Resulting in the test result below:įigure 5: Partially successful test Permissions required to perform unit tests in SQL Server Data Tools: The only problem remaining now is that the user executing the test will be your machine name in the domain, and it probably doesn’t have read permissions to whatever database you are going to run the test on. So now when you check in, as part of the build process, the test will be executed. This search string will search recursively through directories to find all dlls matching the pattern in the binary directories.įigure 4 Test settings in build definition By default it specifies a pattern you can use for catching all dlls having “test” in their name. Under Basic -> Automated Tests -> Test Source click the ellipsis (…) and make sure that you’re test assembly is listed there. In the Items to build menu make sure that all your projects or the solution are selected. On the Trigger menu choose Continuous integration:Įxpand the Process menu to show all the details. Give a name and a description to your build. You can also use the one from the previous blog post included in the project and edit it to suit your needs In the Build menu from the home page of Team Explorer click New Build definition: Remark Now I want this script to run as part of my check-in process after the database has been deployed to my integration instance. If you remember from previous post, I created a simple unit test to check if my continuous deployment script had worked correctly:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |