Wednesday, February 22, 2012

VS2010: build errors when building .net 3.5 application on visual studio 2010

I have downloaded Kigg from codeplex, when I tried to build the web project, I was facing the below errors

Error 1 The type 'System.Web.Routing.RouteValueDictionary' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.dll' and 'c:\Windows\assembly\GAC_MSIL\System.Web.Routing\\System.Web.Routing.dll' d:\svn\kigg\kigg\Source\Web\Views\Membership\Detail.aspx 21 Kigg.Web Error 2 The type 'System.Web.Routing.RouteValueDictionary' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.dll' and 'c:\Windows\assembly\GAC_MSIL\System.Web.Routing\\System.Web.Routing.dll' d:\svn\kigg\kigg\Source\Web\Views\Membership\Detail.aspx 27 Kigg.Web Error 3 The type 'System.Web.Routing.RouteValueDictionary' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.dll' and 'c:\Windows\assembly\GAC_MSIL\System.Web.Routing\\System.Web.Routing.dll' d:\svn\kigg\kigg\Source\Web\Views\Membership\Detail.aspx 34 Kigg.Web


Searching for a solution, I didn’t find much on this error, only this post here

And it was referring to

Following the steps

I opened the file Kigg.Web.csproj

Searched for AspNetCompiler, found it here

<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\Web" /> </Target>

added the toolpath parameter to be like

<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\Web" ToolPath="C:\Windows\Microsoft.NET\Framework\v2.0.50727"/> </Target>

Reloading the project after that, I was able to build successfully

Tuesday, February 21, 2012

VS 2010: Could not load assembly Microsoft.VisualStudio.Web.Runtime

I was facing this error below while building a web project

Error    101    Could not load file or assembly 'Microsoft.VisualStudio.Web.Runtime, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.  

Doing some search, I found someone facing the same error,

He has been advised to remove the Microsoft Inspector, I removed it, and I was able to build successfully.

Saturday, February 18, 2012

MS UnitTestFramework: CollectionAssert.AreEquivalent Failing for 2 identical lists

I was doing assert for 2 lists with MS unit test framework, I knew the 2 lists were the same, have the same elements, but strangely it was failing with the below error
Failed    GetCombinationsTest    MyUnitTesting    CollectionAssert.AreEquivalent failed. The expected collection contains 1 occurrence(s) of <System.Int32[]>. The actual collection contains 0 occurrence(s).     
I was very surprised, I tried to look form something wrong I did, couldn’t find any
Lastly I wanted to test the AreEquivalent method
So I have initialized the expected and the actual  the same way

List<Int32[]> expected = new List<Int32[]>(); expected.Add(new Int32[] { 1 }); expected.Add(new Int32[] { 2 }); List<Int32[]> actual = new List<Int32[]>(); actual.Add(new Int32[] { 1 }); actual.Add(new Int32[] { 2 }); //actual = target.GetCombinations(); Assert.AreEqual(expected.Count, actual.Count); CollectionAssert.AreEquivalent(expected, actual);
By this I am pretty sure that they are the same, running the test again, still it was failing with the same error

So there must be something wrong with CollectionAssert.AreEquivalent
I have tried also AreEqual method
It was giving another error
Failed    GetCombinationsTest    MyUnitTesting    CollectionAssert.AreEqual failed. (Element at index 0 do not match.)   

I thought to give Nunit a shot with the same method, it was passing
I have tried with MS doing collection for list of int, like below, and it was passing

            List<int> expected = new List<int>(new int[]{1,2,3});
            List<int> actual = new List<int>(new int[] { 1, 2, 3 });
            CollectionAssert.AreEqual(expected, actual);

So while doing assertion for simple list of int, it is passing, but for list of array if integers, somehow it is not passing for the same lists

Monday, February 13, 2012

MS CRM4: Editing read only or hidden fields set by JS on the fly

we had a CRM form with some fields set as read-only by JavaScript, we wanted to edit one of these fields, and the form was published to production
The normal way to edit it is to comment the javascript then edit the field then uncomment it back
We thought of another way, using multi edit feature, created another dummy record, then selected both records, and from more actions select Edit
The form will be opened, nut non of the javascript will be executed, so all fields will be displayed in normal mode, read only and hidden fields can be edited
Then you will be able to update the record without any change in customizations.
Don’t forget to delete the dummy record Winking smile

jmeter: Reading results from csv or xml files

I run a couple of tests, saved results to CSV/XML  files. later I was trying to open these files by excel or any editor, I was hoping to analyze the results with excel and draw graphs as I need, but it wasn’t very clear to me when  I opened it by excel, what the values represents, as there was no column headers.

I looked online for some tools to do this job, but couldn’t find any simple ones, finally I remembered that there is a browse button inside the Aggregate Graph sampler, so I added one, browsed to the results file, and I was able to display the results and generate graphs also


The good thing also is that I can copy from the table inside jmeter to excel and I know the label from each column from jmeter

The same also can be applied with summary report, add a summary report sampler to your test, open the csv/xml file, and then you can see the results

Creating lots of test data on the DB with the help of excel

It was required for some scenario to create some data, and checking the data that needs to be added, I found that it is all in one table with some id that needs to be different for every record. so the first thing and simplest thing I thought off is to use excel to generate lots of insert statements

First I opened the DB client, and generated one insert statement with valid data

Second I opened excel, pasted the excel statement, divided it into cells, and kept the ID in a separate cell


I made the ID to be incrementing in each row, then copied the rest of the cells to whatever number I needed of records


Last, I took all these rows, pasted it in my DB editor, then executed, all records are created and now I have lots of test data to be used in my testing

Friday, February 10, 2012

Creating set of folders for test data with specific IDs

I have been given 150 ID and was told to create folders matching already existing folders for some other IDs. The IDs are to be used as a test data and the folder must exist for each ID to be valid.
I took some time to think how to do this efficiently and in a smart way saving time and effort, and I thought of something to be done
First I went to the ID folder that I already have, did select all, then copy and past several times at the same location, this will create multiples of this folder depending on how times you do select all, copy, past. No of end folders = 2^n, then I adjusted the number so that I have 150 only
Now I have 150 folder but with incorrect names, Next I should rename to my IDs
Second I opened command prompt, went to that folder that contains the 150 folder, typed dir command and set the output to text file
dir /w >temp.txt
No I have a text file containing the 150 folder name, the temp names
Third, I opened excel, and in blank sheet, first column I entered “ren “, second row I pasted the 150 temp folder names, third column I pasted the IDs, fourth cell I concatenated all the previous cells. Make sure to replace [ , ] with “
No I have 150 rename command from the old temp folder names to the new IDs
Last, I selected  the 150 ren command, copied them, then in the command prompt, I did a right click then selected past. The 150 ren command will be executed
Now, I have my 150 folder for my 150 ID created in a smart and efficient way

Of course there are other ways to do this, like later, I did a small program to create folders just with one click.

Thursday, February 9, 2012

Recycling data for performance and automation tests

We had some scripts that performs some functions on our data, mainly change of status. we wanted to repeat the scripts over and over, for the performance testing and automation also.

At the beginning I thought of having a large set of data, and to use from this pool of data, and remove what we use.

Also I thought of having my script steps creating the data at the beginning, and doing the reverse processing at the end of the script, so that it can be used again, this is not always possible with all scripts

Another option I thought of, is to connect to the DB and to get the data on the fly, but this is not always possible and depends on the tool.

Lastly I thought of creating a trigger on the DB, so that when the status changes for example, it is set back as it was.

Al these solutions can be used according to the scenario and the processing that is done on the data.

Tuesday, February 7, 2012

jmeter: Validate regular expression extractor

I had some extractors in my test, and when I was looking on the request using the extracted values, I noticed that it is not coming correctly. I looked for someway to validate this extractors to see whether I did it correct or not.

First I made sure that I am using the variables correctly in my test

So if the regular expression Reference Name is param1, it should be used as ${param1}

Second, I found that the regular expression can be verified from the “View Results Tree”, so I went to the request, then selected the Response Data tab in the details panel as below


Then at the bottom, I have entered regular expression in the search box, and checked the Regular exp. check box

at first it wasn’t bringing any results, because there is ? in the regular expression that needs to be escaped

when I changed ? to \?, results was found and highlighted in the response

Screenshot-2012-02-07_11.48.15     Screenshot-2012-02-07_11.48.31

Using this method I was able to verify and correct the regular expressions for the regular expression extractor

Thursday, February 2, 2012

JMETER: using parameters from csv file

I wanted to parameterize my requests, like the login for example, to be able to use different users
looking for some help from the web I found this useful article
I followed the article, created users.csv file with user names and password like the below
user1, password
user2, password
Then added CSV Dataset Config to my requests, set it like below
Next i went to the request and changed the login info to ${user} and ${password}

JMETER: Extracting values using regular expression extractor

We were trying jmeter to do our performance test, one of the issues we faced is that we needed to extract values from pages to be used in next requests

to do so we need to add Regular Expression Extractor to the request, and to set the extractor properties

The most important part is the Regular Expression property

Getting some help from

I used a general form like the following, to extract readme.txt from name="file" value="readme.txt"

we use Regular Expression

name="file" value="(.+?)"


name="file" value="([^"]+)"

If there is no double quotes  at the end, then it will be like