Monday, February 16, 2009

SQL 2005 - Error: 26 - Error Locating Server/Instance Specified)

One of my colleague added a database project for deploying the database before unit test is run. Whenever I tried to open the solution I got the error as below

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

To resolve the problem perform the following

Change the VSTS Options; From Tools -> Options -> Data base Tools -> Design Time - Validation Data base -> Connection Options -> SQL Serevr Instance Name = Blank.

How to remove Recent Projects from Visual Studio 2008 Start Page

Being a tester I had never worked on Visual Studio before. I used to work with VB 6.0in my early career days. Since then I got not chance to create any new projects.

Given responsibility to setup TFS, Continuous Integration and also white box testing I had to create projects every now and then, which resulted in a never ending list of projects in my start page. No matter how many I delete from my local RnD folder the list didn't clear.

Below list helped me do that

1. Close Visual Studio if it is running.
2. Start the Registry Editor (run regedit).
3. Navigate to this registry key: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\ProjectMRUList
4. Then delete the key that has the project you do not want to keep in the list.

The only catch in the last step is you need to keep the File names consecutive.
e.g. If you have File 1 to File 5. Now if you dont need File 3 to appear in the list and if you remove File 3, Files 4 & 5 wont appear either. You need to rename the File 4 and 5 to File 3 and 4 so that the numbering is consecutive.

This will be very easy with VS2010. Its all xaml at the end of the day.

Monday, February 9, 2009

Continuous Integration - Force a build to fail when unit tests fail and create work item

I had to setup continuous build on my TFS2008 machine which had to run a specific set of tests before it created a build (whenever anyone check’s in any code). I was pretty much successful doing that. The process was running smooth but whenever a test used to fail the build used to “Partially Fail” and also it didn’t create a “Bug” and assign it to the person who broke the build. A Bug was assigned to the person who broke the build only when the build used to “Fail”.
I did some RnD in this and figured out a way to force a build to fail whenever a test failed. I wrote the below line in the TFSBuild.proj file

< treattestfailureasbuildfailure > true < /treattestfailureasbuildfailure >
Adding this I thought, as I am forcing the test fail to be treated as a Build Failure, TFS will take care of raising a work item or Bug to the person but it didn’t.
Then I wrote a Target in the same file to create a work item on Test failure.

<UsingTask TaskName="Microsoft.TeamFounadtion.Build.Tasks.CreateNewWorkItem"

AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll" />

<Target Name="AfterTest">

<!-- Refresh the build properties. -->

<GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"


Condition=" '$(IsDesktopBuild)' != 'true' ">

<Output TaskParameter="TestSuccess" PropertyName="TestSuccess" />


<!-- Set CompilationStatus to Failed if TestSuccess is false. -->

<SetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"



Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' ">





Description="The CreateNewWorkItem task created this bug."



Title="Unit Test Failure in $(BuildNumber)"



Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' ">