Thursday, 2 February 2017

Specify build steps for creating New Build Definition in TFS 2015 to run Coded UI Test Scripts

Steps for creating New Build Definition in TFS 2015
Þ    Create Coded UI solution check in your code to TFS.
Þ    Click “New Build Definition” Under Team Explorer Window(see screenshot below), This will navigate you to the TFS screen
Þ    Now select “Visual Studio” as shown below and hit Next button at the bottom
Þ    On the next screen by default your team project will be selected, Verify that under “Repository” drop down your Test Plan name should be visible, under “Build agent queue” build agent should be visible. Now Hit “Create” button at the bottom
Þ    Screen will be open with some default steps already added let these steps be there and click on “+ Add build step”(highlighted yellow in below screenshot) and add the step as shown in below screenshot
Þ    Now disable “Visual Studio Test” by unchecking the Enable checkbox (highlighted yellow below) or click the dropdown arrow at the left side of the step and choose disable

Þ    Now let’s work on individual tabs:
o   Under Build and Options tab you have to do nothing
o   Click on Repository tab, under Mappings navigate to the folder which contains your solution

o   Move to Variables tab, Set “system.debug” to true, here set the “password” variable (this is Admin user password) by clicking “+ Add variable ” button



o   Nothing to be done on Triggers, General, Retention & History tab

Þ    No let’s work on Build steps: Click on Build tab

o   Nothing to be done on “NuGet Installer”, Click on “Visual Studio Build” step in Solution text field navigate to the .sln file of your project, that’s it on this screen


o   Click on Windows Machine File Copy, In Source text box navigate to project folder, In Machines text box provide the FQDN of the machine on which you want to run your test script, In Password  textbox provide the variable name you declare under “Variable” tab, In the Destination Folder textbox Provide the location where u want to drop the solution.


o   Click on Visual Studio Test Agent Deployment-> Click Manage(Highlighted below), this is used to configure Test Machine Group



o   Following screen will be open, Click on + button

o   In the following screen, Provide Machine Group name, Insert the Admin credentials, Select HTTP, Under Machines provide the FQDN- hit Done button

o   Come back to build screen, Now here select the Newly created Test Machine Group from the drop down, Provide the Admin credentials in Agent Configuration section, check the Interactive Process check box

o   Click on Run Functional Tests, Provide the Machine group created in earlier steps, Enter the same location in “Test Drop Location” which you have set in “Windows Machine File copy” build step, in Test Assembly provide the .sln name (e.g., if “AutomationTest.sln” is the name so you can write **\*Automation*.dll)

Þ    Now save the build, Login to the Test Machine where the Test Script will run finally
Þ    If any Test Data folder is used I should be copied to Test Agent machine manual in C:Drive
Þ    Install Microsoft Access Oledb 12.0 on test machine, if required
Þ    Installed Windows Management Framework 4.0 on this machine.(Link below) 
Þ    Copy the ConfigureWinRM.ps1 to target machine on Desktop
Þ    Open PowerShell on Test Machine- navigate the location where you have copied above file using CD command
Þ    Run on PowerShell .\ConfigureWinRM.ps1 FQDN http (This will prepare the system to be connected using FQDN and http)
Þ    If execution restricted- run this command in PowerShell(Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass)
Þ    Now run command ( .\ConfigureWinRM.ps1 FQDN http ) on PowerShell
Þ    Select Y to all option
Þ    On PowerShell run “winrm QuickConfig”  command (This will Quickly configure the WS-Man service)
Þ    Then Enable-PSRemoting cmdlet configures the computer to receive Windows PowerShell remote commands that are sent by using the WS-Management technology.
Þ    Run following command on PowerShell (run PowerShell as administrator)
Þ    PS C :\> Enable-PSRemoting
Finally we are good to Queue build, go to TFS and Queue the build and see the magic.
Best of luck J






1 comment:

  1. Kindly share if this article needs improvement or it is helpful

    ReplyDelete