Saturday, April 30, 2011

VS 2010 - Different Timeouts in Testsettings file

The following are the different types of timeouts that can be configured in testsettings file:
  • agentNotRespondingTimeout
  • deploymentTimeout
  • runTimeout
  • scriptTimeout
  • testTimeout
Setting these timeouts are not very obvious when the testsetting is opened with 'Test Settings Editor'. Hence, open the testsettings file in 'XML (text) Editor'

You can then add various timeouts in milliseconds in the Timeouts node under the Execution node.
<TestSettings name="Local" id="46d8e12e-16c0-4ba4-9dd9-eda66fb2ccc6" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
   <Description>These are default test settings for a local test run.</Description>
   <Execution>
     <Timeouts agentNotRespondingTimeout="1800000" deploymentTimeout="" runTimeout="1800000" scriptTimeout="1800000" testTimeout="1800000"/>

Monday, April 18, 2011

VS 2010 - Create Load Test Repository

One day I found that my Load Test Reporsitory is missing and hence I was not able to run the load tests.
The load tests were failing with the error:
---------------------------
Microsoft Visual Studio
---------------------------
Error occurred running test. The load test results database could not be opened.  Check that the load test results database specified by the connect string for your test controller (or local machine) specifies a database that contains the load test schema and that is currently available.  For more information, see the Visual Studio help topic 'About the Load Test Results Store'.   The connection error was: An error occurred while attempting to create the load test results repository schema: Cannot find the object 'LoadTestTestCaseSummary', because it does not exist or you do not have permission.
---------------------------
OK  
---------------------------

To resolve this issue, I followed the below steps:
1) Open VS command prompt in elevated mode (Run As Administrator)
2) Run the command "cd C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE"
3) Run the command "SQLCMD /S localhost\sqlexpress /i loadtestresultsrepository.sql "

Sunday, March 27, 2011

TFS 2010 - hexadecimal value 0x07 is an invalid character

I recently encountered an issue where my tests in lab management were getting aborted. I really had a hard time figuring out what was really going wrong. I looked into the test run log in the Test Manager->Analyze Test Runs but nothing obvious showed up. I also enabled diagnostic logging in my lab build definition but again nothing showed up.
I then used tcm.exe and created a new test run using "tcm run /create". Then I executed the run using "tcm run /execute" and I got the error: "hexadecimal value 0x07 is an invalid character"
Then I looked into the intellitrace logs in "%localappdata%"\VSEQT\QTController. Here I found that there was an invalid xml in my Assert statement.
Fixing the xml in the Assert solved my problem.

Why http://localhost does not work?

I encountered an issue recently where I was able to browse the Default Web Site using http://IPAddress but was not able to browse it using http://localhost
The reason for that was the Default Web Site Bindings.
If you click on Default Web Site, then click Bindings on the Actions pane, you will see the Site Bindings. Edit the Bindings and in the IP Address drop down, select "All Unassigned" instead of a specific IP Address.

Tuesday, March 8, 2011

TFS 2010 Build: Keep folder tree structure

There are two approaches :
=============================================
Approach 1
=============================================

To keep the output structure, you have to make TFSBuildHost not pass OutDir
to MSBuild and  custom the output path of each project.
  1. Open the build process file, navigate to Compile the Project Sequence, edit the property of Run MSBuild for Project Activity.
    • Set OutDir to empty (just make the textbox is empty)
    • set CommandLineArguments to String.Format("/p:SkipInvalidConfigurations=true {0} /p:TeamBuildOutDir=""{1}""", MSBuildArguments, outputDirectory)
  2. Modify each project file in the solution.
    • Check out project file to Edit.
    • Open project file  with notepad.
    • Find <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
    • Use following code to replace the default OutputPath Property.
                   <OutputPath Condition=" '$(TeamBuildOutDir)'=='' ">bin\release\</OutputPath>
                   <OutputPath Condition=" '$(TeamBuildOUtDir)'!='' ">$(TeamBuildOutDir)\<ProjectName>\</OutputPath>
                  The word “Release|AnyCPU” is dependent on the value of “ConfigrationToBuild”  in   TFSBuild.proj.      
    • Save project file and check in.
=============================================
Approach 2
=============================================
  1. Open the build process file, navigate to Compile the Project Sequence, edit the property of Run MSBuild for Project Activity.
  2. Set OutDir to empty (just make the textbox is empty)
  3. Set OutDir to System.IO.Path.Combine(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(localProject))
  4. In the build definition, instead of specifying a single solution, specify the projects individually

Monday, March 7, 2011

TFS 2010 Deployment Items - Prefer DeploymentItem attribute

There are multiple ways to configure deployment items when working with TFS 2010. Lets have a look at them one by one.

Local.testsettings
You can specify the deployment items in the Deployment section of Local.testsettings
Visual studio by default picks up the testsettings while running the tests.
If you are using command line, then you will nedd to pass the /testsetting parameter to mstest
If you are running your tests as part of build process, you need to specify the Local.testsettings in the build definition.

Lab Manager TestSettings
If you are running the test as part of lab process, then the Visual Studio testsetting is not used. You will need to create a test setting in lab manager and the files that are specified should be present on the test controller or be under a shared location.
To use this testsetting, you will have to specify it as part of your test plan or lab build definition.

DeploymentItem Attribute
The best way to make your tests work under all circumstances without making any changes is to use the DeploymentItem attribute on your test class/method.
No matter how you are running your tests, the deployment items will always be copied to the test execution folder.