Category Archives: ALM

Category for all elements of Application Lifecycle Management

VSO: Requesting feedback, using the feedback tool, and viewing feedback

Visual Studio Online provides a feature for requesting feedback on an application from your stakeholder users. You can provide a description of what it is you’d like feedback and could include steps on how to use the feature. The stakeholders in turn are able to provide feedback through text, videos and screen shots.

You can request feedback from any of your users, but it’s more marketed as a way for stakeholders to get a look at the app and of course… provide feedback.

Creating a stakeholder user

Creating a user as a stakeholder is just as simple as creating any user on VSO. Clicking the Users tab will display all current users and allow a new one be created with a stakeholder license.

20150202_RequestFeedback2

Requesting Feedback

In order to see the request feedback link, you have be inside one of your team projects.

20150202_RequestFeedback3

Clicking on one will open up the project view and at the bottom of the page will be the request feedback link

20150202_RequestFeedback4

Using this feature requires either an Advanced license or an MSDN license to use, if you don’t have them and try, you’ll see this:

20150202_RequestFeedback1

If you do have one, you’ll see:

20150202_RequestFeedback5

The first requirement is to choose one or more stakeholders / other users. Whoever you want to help provide feedback, add them to the list.

The second option to tell stakeholders how to access the application. There are three radials for Web Application, Remote Machine, and Client Application. The Web Application allows  you to provide a URL/URI. The Remove Machine option allows you to enter the name of a Remote Machine. Finally,  the Client Application option allows you to enter the local path the application. The larger text box allows you to provide instructions on how to launch the application in which you listed.

20150202_RequestFeedback6

Most likely, if you’re actually going to be sending this to a stakeholder, you’re message and URL/URI will be a tad bid different.

The final requirement is a description of the areas of focus you’d like feedback on. You can attach up to 5 areas of focus.

20150202_RequestFeedback7

Once done with all the information, you can either do a quick preview of what the email will look like when sent, or you can just go ahead and send it.

Giving Feedback

Once the feedback request has been sent, it’ll pop up in the selected stakeholders e-mails like so:

20150202_RequestFeedback8

If the stakeholder has never provided feedback before through the feedback tool, they must install the tool.

20150202_RequestFeedback9

Running the install tool displays the usual Visual Studio style install window.

20150202_RequestFeedback10

Once installed, follow the URL from the e-mail and it’ll open up the feedback client

20150202_RequestFeedback11

Clicking next then provides a nice reply form for the stakeholder to be able to record their feedback via audio/video, provide screen shots, attach any extra files, and a comment box with some simple text manipulation.

20150202_RequestFeedback12

Clicking next will display the submit page which provides a ‘Thank You’ for providing feedback and shows that the feedback is saved to VSO.

20150202_RequestFeedback13

The option to submit the feedback and close the tool is at the bottom. Once clicked, the feedback is submitted and the tool closes.

Viewing the feedback

The feedback can be viewed in the project’s backlog in which the feedback request was initiated from. I’m assuming the iteration that gets chosen for the feedback work item is whatever the current is set as.

20150202_RequestFeedback14

Advertisements

Using Git with Visual Studio Online

Visual Studio Online provides two ways to do Source Control, either via Team Foundation or Git methodology.  TFS provides a Centralized Version Control System (CVS) while Git provides a Distributed Version Control System (DVCS). A DVCS like git, gives you all the functionality of a CVS, but locally. This makes working offline a bit easier to manage and you can later sync your changes to the server.

Creating a Git Team Project in Visual Studio Online is the same way you’d normally create a team project. Click New… and in the window that appears, the drop down for Version Control, choose Git.

11192014_GitTeamProject

When you load connect to the Team Project in Visual Studio, if you don’t have the Git Extensions, you’ll be prompted to download two separate ones which each require a Visual Studio restart. Just click the links to start the download from the prompts that appear.

Once all the extensions are done and you’re connected again, you must clone the repository to your local machine.

11162014_ConnectedToGitProject

Which you’ll then choose where to clone it to

11162014_CloningRepository

Since there’s nothing in the Team Project, it’s time to create something. I created an F# project as I want to continue learning F# while using Git. I also used the code from my last blog.

11192014_GitNewProject

Now that I have made some changes, I can commit them locally via the Changes button in the Team Explorer Home.

11192014_FirstCommit

When you commit, an alert displays telling that the commit has been created locally and that in order to upload the changes to the server you have to do a Sync.

11192014_CommitAlert

Clicking on Sync will bring you to the Unsynced Commits page.

11192014_Sync

To send your changes to the server, click Push. I did a push instead of a sync because there’s currently nothing residing in the repo.

Now normally when creating coding in Git, you create your own branch to work in then merge the changes to the master branch when your ready. Branches that you create can be shared between team members and before being fully merged into the Master branch can be reviewed by a Code Reviewer.  I’m going to create a new branch, make some changes, then merge them into the Master branch.

11192014_Branch

11192014_BranchCreation

The branch you just created is now the branch your coding in

11192014_TargetBranch

Now I’m going to make some changes to the project and commit to my local ‘Phils’ branch

11192014_CommitToCreatedBranch

And again the commit alert

11192014_CommitToCreatedBranch_CommitAlert

Problem is – it doesn’t show I can push my changes.

11192014_BranchNotPublished

So I must first publish the branch I created.

11192014_PublishBranch

11192014_BranchPublished

Now I can Sync my changes to my branch.

11192014_BranchSync

I can now switch between branches and see the difference between the two.

My master branch:

11192014_BranchMaster

And my Phils branch:

11192014_BranchPhils

A quick switch just by hitting the drop down

11192014_BranchSwitching

Now, if I want my changes to be reflected in the main branch, I must execute a merge.

11192014_BranchMerge

And an alert appears saying that a commit has been made

11192014_BranchMergeAlert

If I go back and check my current master branch,  it will have my changes in it

11192014_BranchMasterLocallyChanged

But I still have to sync the changes to the source version.

11192014_UnsyncedOutgoingCommit

Hit sync and boom.

11192014_BranchMasterSynced

Everything is copacetic.

2012-02-14-hold all this slinky

CUIT: Getting Started with Data Driven Tests

Data Driven CUITs allow you to record a set number of steps and then use a data source as a list of parameters to change the values that are either chosen, entered, or have been asserted in a test. If numerous sets of parameters are supplied, the test will run itself multiple overs using the list of supplied parameters.

Since this is my first attempt at creating a Data Driven variation of CUIT, I created a simple CUIT which contains two methods. I used Windows Calculator as my test dummy in this. The first method adds 1 + 2 by clicking ‘1’  -> ‘+’ -> ‘2’ -> ‘=’. The second method asserts that 1 + 2 equates to 3.

The process can be summed up in about 3 (relatively) simple steps

  1. Create a data set
  2. Add the data set to a test method
  3. Map the test values from the Data Set

Requirement
A using statement must be added when dealing with Data Driven tests

using Microsoft.VisualStudio.TestTools.UITesting.WinControls;

Creating the Data Set

In order to create the file to be  used, simply add a new text file to the solution by right clicking on it. The file will need a .csv extension (Yes, add a text file to the solution and during creation append .csv instead of .txt). Once the file has been created, a table of values can be created. For each parameter that you want to supply a new value for, add a new column for it. For each new repetition of the test, a new row of values to fill the columns is needed.

On my test there are three parameters that I want to give new values to. These values are: The first number pressed, the second number pressed, and the value asserted. This means that my data file will need to include columns for those parameters. If I want the test to run 3 times, then the file will need 3 rows of data.

This is what the contents of the file would look like:
Num1, Num2, Sum
2, 3, 5
3, 4, 7
4, 5, 9

Add the Data Set to a TestMethod

So far there’s only a file with the values we wish to use for the parameters. Technically, the file could be used for multiple Test Methods. In order to tell the test which method we wish to associate it with, a Data attribute must be appended to the Test method attribute.

[DataSource(“Microsoft.VisualStudio.TestTools.DataSource.CSV”, @”c:\users\phillipwolf\documents\visual studio 2013\Projects\CodedUITestProject1\CodedUITestProject1\data.csv”, “data#csv”, DataAccessMethod.Sequential), DeploymentItem(“data.csv”), TestMethod]

In the DataSource attribute, the first string determines the type of data source, the second is the file path (which requires an @ symbol due to the spaces), and I’m not entirely sure what the last one is yet aside from knowing to match it to the file’s name. I found the DataSourceAttribute class help page and those constructors don’t seem to match these.

If the test was ran at this moment, with only the Data Source have being added – The test would run through three times, but with the default values each time. This is because the test realizes that there are three rows of values in my data source but it doesn’t know what parameters to match to which column.

Map the Values from the Data Set

Before the methods run in the Test Method, the values on the UIMap that the methods in the test use need to be mapped to the correct columns in the data set.

Currently, my UIMap looks like this

1

So my three values to map where the first number button click, the second number button click, and the value asserted.

The First Value

According my UIMap, UIItem1Button is the object that selects the ‘1’ button (Under AddNumbers there’s the actions taken during recording. If you select one of those options, the code equivalent will highlight on the right side). Objects that interact with the GUI use the properties of the item on the screen in order to find them. This means that we need to change the search properties of UIItem1Button.

this.UIMap.UICalculatorWindow.UIItemWindow.UIItem1Button.SearchProperties[WinButton.PropertyNames.Name] = TestContext.DataRow[“Num1”].ToString();

The first part is pretty easy to figure out. UIMap.UICalculatorWindow.UIItemWindow.UIItem1Button is directly from the UIMap image above. SearchProperties[] is then a property of the button which the test uses to find the control on the application. The controls property is then placed within the brackets, in this case the name will be replaced. After the = contains the column reference via TestContext.DataRow[“NameOfTheColumn”].ToString(); This makes the Search Properties equal to the respective column .

The Second Value

The second number button would have it’s parameters set exactly the same way as the first number button

this.UIMap.UICalculatorWindow.UIItemWindow2.UIItem2Button.SearchProperties[WinButton.PropertyNames.Name] = TestContext.DataRow[“Num2”].ToString();

The Assertion

The assertion throws in a curveball and you don’t use the UICalculatorWindow on this one. Instead, assertions have a class created called assertionNameExpectedValues and then the name of the text control.

this.UIMap.ValidateSumExpectedValues.UIItem3TextDisplayText = TestContext.DataRow[“Sum”].ToString();

After the equals follows the same pattern as before for mapping the correct column’s values.

Running the test now will run it three times in a row, adding the first two column values from the data source and then asserting the third column.

The final product of the code looks like

[DataSource(“Microsoft.VisualStudio.TestTools.DataSource.CSV”, @”c:\users\phillipwolf\documents\visual studio 2013\Projects\CodedUITestProject1\CodedUITestProject1\data.csv”, “data#csv”, DataAccessMethod.Sequential), DeploymentItem(“data.csv”), TestMethod]

public void CodedUITestMethod1()

{

// To generate code for this test, select “Generate Code for Coded UI Test” from the shortcut menu and select one of the menu items.

this.UIMap.UICalculatorWindow.UIItemWindow.UIItem1Button.SearchProperties[WinButton.PropertyNames.Name] = TestContext.DataRow[“Num1”].ToString();

this.UIMap.UICalculatorWindow.UIItemWindow2.UIItem2Button.SearchProperties[WinButton.PropertyNames.Name] = TestContext.DataRow[“Num2”].ToString();

this.UIMap.ValidateSumExpectedValues.UIItem3TextDisplayText = TestContext.DataRow[“Sum”].ToString();

this.UIMap.AddNumbers();

this.UIMap.ValidateSum();

}

PowerShell: Import CSV to SQL via SQLBulkCopy

This script is made possible by the Out-DataTable module provided by Chad Miller. In order to use this script, copy the code from the link into a script editor. Save it as a .psm1. Use Import-Module to import the script and use Out-DataTable as a cmdlet.

First you’ll need the usual ConnectionString to your server. It should look a little like
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = “Server={yourServerPath};Database={yourDatabase};User ID={yourUsername};Password={yourPassword}”

PowerShell provides a built-in way to import CSV files into the Shell via the Import-CSV cmdlet. The result is a nice Object in the shell. The problem is, you generally had to do a lot of modifications to that object to mold it into a DataTable to actually make any use of it. That was, before Out-DataTable turned it into a simple pipe cmdlet.

$CSVDataTable = Import-Csv ‘C:\Path\To\Your\CSV.csv’ | Out-DataTable

Depending on how the destination table and the CSV match up, your BulkCopy command could be as easy as

$sqlBulkCopy = New-Object (“Data.SqlClient.SqlBulkCopy”) -ArgumentList $SqlConnection
$sqlBulkCopy.DestinationTableName = “dbo.yourTable”

The SqlBulkCopy Class requires use of one of it’s multiple constructors, the simplest being SqlBulkCopy(SqlConnection). SqlBulkCopy also requires you to define the table you intend update via it’s DestinationTableName Property. This example  so far assumes that your destinations table’s columns match up with your csv’s columns. However, if your table has say, a unique ID in the first column that isn’t in your CSV, you’d have to some how tell BulkCopy which columns go where. This can be done through ColumnMapping.

$ColumnMap1 = New-Object System.Data.SqlClient.SqlBulkCopyColumnMapping(x,y) Allows you to reference the source’s(x) column to that of the destination’s(y) column. In order to add this column reference to BulkCopy $sqlBulkCopy.ColumnMappings.Add($ColumnMap1)

Here’s how you could add multiple column mappings

$ColumnMap1 = New-Object System.Data.SqlClient.SqlBulkCopyColumnMapping(0, 1)
$ColumnMap2 = New-Object System.Data.SqlClient.SqlBulkCopyColumnMapping(1, 2)
$ColumnMap3 = New-Object System.Data.SqlClient.SqlBulkCopyColumnMapping(2, 3)
$sqlBulkCopy.ColumnMappings.Add($ColumnMap1)
$sqlBulkCopy.ColumnMappings.Add($ColumnMap2)
$sqlBulkCopy.ColumnMappings.Add($ColumnMap3)

Finally, Once you’ve got your columns mapped correctly, open the connection and WriteToServer().

$SqlConnection.Open()
$sqlBulkCopy.WriteToServer($CSVDataTable)
$SqlConnection.Close()

Here’s the script in all total

$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = “Server={yourServerPath};Database={yourDatabase};User vID={yourUsername};Password={yourPassword}”

$CSVDataTable = Import-Csv ‘C:\Path\To\Your\CSV.csv’ | Out-DataTable

$sqlBulkCopy = New-Object (“Data.SqlClient.SqlBulkCopy”) -ArgumentList $SqlConnection
$sqlBulkCopy.DestinationTableName = “dbo.yourTable”

$ColumnMap1 = New-Object System.Data.SqlClient.SqlBulkCopyColumnMapping(0, 1)
$ColumnMap2 = New-Object System.Data.SqlClient.SqlBulkCopyColumnMapping(1, 2)
$ColumnMap3 = New-Object System.Data.SqlClient.SqlBulkCopyColumnMapping(2, 3)
$sqlBulkCopy.ColumnMappings.Add($ColumnMap1)
$sqlBulkCopy.ColumnMappings.Add($ColumnMap2)
$sqlBulkCopy.ColumnMappings.Add($ColumnMap3)

$SqlConnection.Open()
$sqlBulkCopy.WriteToServer($CSVDataTable)
$SqlConnection.Close()

CUITs: Automating Web Page testing and the Ajax trickster.

(If you’re not interested in my short story and want to skip ahead to the issue being faced and the resolution  go to THE PROBLEM heading.)

So for the past few weeks I’ve been attempting to come up to speed on using CUITs to automate my every testing needs. One of the items on my testing palette is a web page. There are a couple different languages that can be utilized in order to craft a web page into a beautiful butterfree, such as HTML, CSS, and JavaScript. (Let it be known now that I am NOT  a professional web dev and my experience in web development has been summed up by High School classes and a college course)

As pretty much everyone who’s ever stepped onto the interwebz these days know (thanks to MySpace! :P), HTML is the staple language in creating a website. Anyone can put a few lines of HTML into a notepad document and BOOM a “website” appears (obviously not THAT simple, but you get the idea). A while after the birth of HTML came along this thing called CSS, Cascading Style Sheets. CSS allowed web devs to use HTML primarily for placing elements on the screen, not for making it look pretty. You could then create a single CSS document that would be linked to the HTML pages which then would then add the “makeup” to the web page giving it the polished look. Then, to make websites even more interactive and to further increase the coolness factor, JavaScript began to be implemented in the web pages as well. Now JavaScript does a bunch of cool stuff like running client-side scripts, controlling the browser, altering the pages content and asynchronous communications. This my friends, is where my issues began.

After weeks of being trumped on the same issue, someone smarter than I pointed out something in the websites code I was attempting to automate. The website uses JavaScript and implements a technology known as AJAX. AJAX stands for Asynchronous JavaScript And XML and can also be known as AJAJ, Asynchronous JavaScript And JSON.

AJAX Wiki

http://en.wikipedia.org/wiki/Ajax_(programming)

Ajax (also AJAX; /ˈeɪdʒæks/; short for asynchronous JavaScript + XML)[1][2][3] is a group of interrelated Web development techniques used on the client-side to create asynchronous Web applications. With Ajax, Web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data can be retrieved using the XMLHttpRequest object. Despite the name, the use of XML is not required; JSON is often used instead (see AJAJ), and the requests do not need to be asynchronous.[4]

Ajax is not a single technology, but a group of technologies. HTML and CSS can be used in combination to mark up and style information. The DOM is accessed with JavaScript to dynamically display – and allow the user to interact with – the information presented. JavaScript and the XMLHttpRequest object provide a method for exchanging data asynchronously between browser and server to avoid full page reloads.

Upon Googling (This hasn’t been added to the dictionary yet? Whaatttt?)  Problems with CUITS and AJAX, we discovered that the version of AJAX we were using causes conflicts with the CUITs.

Enough Short Story.

THE PROBLEM

The problem I’ve been exhibiting is that when I record a test through Visual Studio’s Test Recorder, the playback of the test would be incorrect. Events were not being executed upon clicking certain elements on the page and therefore the data wouldn’t be sent or retrieved correctly.

THE CAUSE

The website in question, uses AJAX calls when the button I was attempting to test is clicked.  The AJAX calls were responsible for correctly transporting the data to the DB and letting it know I was adding something to the page and then displaying the results on the page. CUITs don’t play nice with the version of JQuery on the web page (v2.0.3), thus concluding in unexpected test results.

THE SOLUTION

The solution to the issue was simple.  One line of code resolved all my issues. Inside the list of local variables (empty by default) for your CUIT.cs file, a single app setting is required.

08302014_AJAXFix

The line

ConfigurationManager.AppSettings["WebWaitForReadyLevel"] = "3";

Is what is required to make the CUIT play nice with AJAX calls to the server. With this single line of code, the doors to Web Page Automation shall be open and rainbows will emit unicorns that twirl sparklers throughout the sky. Seriously, it’s that awesome.

 

Hopefully someone will be able to make sense of my ramblings here and will prove useful!

 

 

MSBUILD: Targets, Tasks and Properties

MSBUILD – From the Start

MSBuild projects files are composed of XML. The simplest form of a project file contains only a Project element.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 </Project>

MSBUILD Properties

Properties of MSBUILD are key-value pairs – a term I’ve heard through working with PowerShell and JavaScript. Static properties that are declared must be done so within a PropertyGroup Element.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <Key>value</Key>
        <Key>value</Key>
    </PropertyGroup>
</Project>

Another example with more meaningful key-value pairs and multiple PropertyGroups

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <AppServer>myApp.myServer.net</AppServer>
    </PropertyGroup>
    <PropertyGroup>
        <WebServer>myWeb.myServer.net</WebServer>
    </PropertyGroup>
</Project>

MSBUILD Tasks and Targets

MSBUILD utilizes two ‘execution elements’: Task and Target. A task is the smallest unit of work in MSBUILD and a Target is a collection of Tasks. MSBUILD comes with many tasks available such as Copy, Move, Exec and Message ( There’s a big list of them on the left-hand pane @ http://msdn.microsoft.com/en-us/library/7z253716.aspx ).

Here is a simple example of declaring a Target with a Task.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="HelloWorld">
        <Message Text="Hello world!" />
    </Target>
</Project>

If you save this into a .csproj file, it can be built by MSBUILD. I saved it as program.csproj and moved a copy of it into

C:\Program Files (x86)\Microsofot Visual Studio 12.0\

Which is why my Visual Studio installation lives – and so does MSBUILD. The reason for moving the csproj file into there was just because I didn’t want to enter in a full path name to the file (which was on another drive).

Now if you open a VS CMD or just a regular CMD and CD to the directory above, you can use MSBUILD on the file.

07292014_MSBUILD2

The syntax is like this: MSBULD <YourCSPROJ> /t:<TaskToRun>

When ran, the results will display as follows:

07292014_MSBUILD3

 

Using Properties, Tasks, and Targets together

So MSBUILD has the ability to declare Properties which can be encased in PropertyGroups and Targets that can implement a various number of Tasks. How are these used together? Like so~

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="HelloWorld">
        <Message Text="Hello world!" />
    </Target>

    <PropertyGroup>
        <HelloMessage>Hello World</HelloMessage>
    </PropertyGroup>
    <Target Name ="HelloFromPropertyGroup">
        <Message Text="$(HelloMessage)" />
    </Target>
</Project>

I left the original Target named ‘HelloWorld’ and added a new PropertyGroup which contains a property with the key ‘HelloMessage’ and value ‘Hello World’. A new Target named HelloFromPropertyGroup is then created with a Message Task. The Message Task proceeds to use the ‘HelloMessage’ property in the Text parameter.

In order to view the results of the new changes, save the file and then enter the new target in MSBuild’s /t parameter.

07292014_MSBUILD5

Once it builds the results display the text from the property.

07292014_MSBUILD6

Creating Build Notifications for Visual Studio Online(TFService)

Builds can take time, time that most people don’t have to sit around and wait for to see if everything checked out OK. Notifications allow for multiple team members to be e-mailed as soon as a build kicks off, if it fails, passes, partially succeeds and a whole lot of other parameters to inform you and you team of what’s going on.

For my examples, I’m going to be using Visual Studio 2013 (free download from VisualStudio.com, trial lasts darn-near forever) and Visual Studio Online for my source code repository.

Build notifications are built-in to VS/TFS and can be easily configured. To start, I opened up Visual Studio and connected to the Team Project I wanted to create notifications for. In the Team Explorer pane, there is a Drop-down arrow which contains ‘Settings’.

TeamExplorerSettings

After clicking on settings, a smorgasbord of options appears for Team Project and Team Project Collection

SettingsInTeamExplorer

The option that we want to set notifications with is ‘Project Alerts’ under Team Project. Since I’m using Visual Studio Online, clicking on Project Alerts opened up a web page to my VSO in order to make the configuration changes.

The page offers BASIC alerts, which are predetermined settings that you can just choose the check boxes you want and have the emails set.

NotificationsBasicAlerts

Then there are the custom alerts that let you choose from a starting point – such as a build failure, MY build completes, A file checked in from a specific path, and so on. You can then build on that alert to include specific projects and other ‘if’ and ‘and’ statements.

NotificationsCustomAlerts