Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Articles On Testing

Wecome to http://www.articlesontesting.com !!!

Best practices in gridview programming

In this article, I will be explaining how to implement selectall functionality for gridview using javascript and reducing postbacks.

What shall be learnt through this post ?
Confused ?
Some javascript, some .net, some asp, some best practices , and some typical customer logged UI
bugs for row selection !

How do we achieve this functionalities ?
1) Check/Uncheck all row check boxes using header checkbox.2) Besed on all row checkboxes check, Check/uncheck of Header checkbox.

We'll use javascript to implement above mentioned functions.

To start with I have a GridView control with a header checkbox and checkbox for each individual record.

<asp:GridView ID="gvEmployee" runat="server" AllowPaging="True"  
            AllowSorting="True" AutoGenerateColumns="False"> 
            <Columns>
               <asp:TemplateField>
                    <HeaderTemplate>
                       <asp:CheckBox ID="chkSelect" runat="server" Text="Select All" onclick = "SelectAll(this)" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelect" runat="server" onclick = "checkAllBox(this)" />
                    </ItemTemplate>
               </asp:TemplateField>
                 <asp:BoundField DataField="EmployeID" HeaderText="EmployeID" SortExpression="EmployeID" />
            </Columns> 
        </asp:GridView>


we have called "SelectAll(this)" function on header check box click and "checkAllBox(this)" on row checkbox click.

<script type="text/javascript">
        function SelectAll(CheckBoxControl) {
            if (CheckBoxControl.checked == true) {
                var i;
                for (i = 0; i < document.forms[0].elements.length; i++) {
                    if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('gvEmployee') > -1)) {
                        if (document.forms[0].elements[i].disabled) {
                            document.forms[0].elements[i].checked = false;
                        }
                        else {
                            document.forms[0].elements[i].checked = true;
                        }
                    }
                }
            }
            else {
                var i;
                for (i = 0; i < document.forms[0].elements.length; i++) {
                    if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('gvEmployee') > -1)) {
                        document.forms[0].elements[i].checked = false;
                    }
                }
            }
        }
       
        function checkAllBox(CheckBoxControl) {
            var row = CheckBoxControl.parentNode.parentNode;
            var GridView = row.parentNode;
            var checkBoxList = GridView.getElementsByTagName("input");
            for (var i = 0; i < checkBoxList.length; i++) {
                var headerCheckBox = checkBoxList[0];
                var checked = true;
                if (checkBoxList[i].type == "checkbox" && checkBoxList[i] != headerCheckBox) {
                    if (!checkBoxList[i].checked) {
                        checked = false;
                        break;
                    }
                }
            }
            headerCheckBox.checked = checked;
        }
    </script>


Hope you enjoyed browsing this post and would chip in with your comments, expectation on the same. 

TFS - Things as tester one should avoid

Are you a Software Tester ?
Do you use the TFS for artifacts tracking ?
Do you have the habit of using Excel to upload the artfacts into TFS ?

Download a query based content in the excel sheet such as Test Case document.
Also download the test steps.
Now from within excel sheet that has been downloaded modify some of the test steps as needed.
Start publishing the content into the TFS.
A huge mess occurs !!!
Did you realize what was that ?
It was a very simple thing that you just messed around with, All your test steps of a single test case becomes part of a single test case.
Now what are the predicaments associates with this shit activity that the TFS did on publish from excel is you will not be able to see all your test steps as separate entities in the MTM, all will be coming up as one step .
Is not that a wierd thing to happen !

Facing issues in configuration wizard for SharePoint web farm creation

What are the typical scenarios that one face when they are in the mid of creating a new web farm ?
  • The database server is not accessible.
What is the reason for this?
It can be a hell lot of things but to start with I would suggest you to start with the database server accessibility from your app server that is the SharePoint server using the ping operation.
  • Just open the command prompt and type ping command and provide the server name - of course the database server name.
  • Now see if the reply comes up or there is a time out.
  • In case there is a time out, you have something to fix up here before proceeding to the next step.
  • Log on to the database server and check for the network share option.
  • If the network discovery is turned off, just enable it from the radio button option.
  • This will enable the ping issue to be resolved.
  • Now go back to the SharePoint server and fire ping command on the database server from there.
  • Most probably the reply will now start coming successfully.
SO you have fixed this problem.
  • Now another issue that comes up very often is that the User Profile Synchronization is not getting started.
What is the reason for this?
User Profile synchronization is something related to access privileges.
  • Just open the SharePoint Central Admin in the deployed machine.
  • Open Security tab from Left Navigation
  • Open General security link.
  • Go To configure Managed Accounts.
  • Verify the presence of the relevant user accounts under this section namely Sql,Farm, Services, Content, UPS.
  • Once again go back to the Security and under General Security open the Configure Service Accounts link.
  • Verify the correct mapping of the managed account with the relevant services on the farm.
  • Most probably the User Profile Synchronization will start working.
  • However if you still keep facing the issue, what will you do ?
  • I have another step to take in such cases.
  • I go the Windows folder in c drive and navigate to the hidden folder Program data.
  • Under that folder navigate to this path -Microsoft - SharePoint - Config
  • Keep a back up of the folder contents.
  • Now find the file named cache , open it and set the content to 1.
  • Try restarting the User Profile Synchronization service.
  • Most probably service would start running.
SO you have fixed this problem.


Another scenario we may come across is related to Search results not coming up
What is this all about ?
Is it something related to the meta data associated with the users, or is it something related to the documents , or may even touch base upon the roles and responsibilities associated with people in general.
Whatever it be something sounds pretty neat and that is the Metadata properties .
Metadata properties are data about data, such as the designation, phone number, email etc of a person.
When we are talking of person what strikes at the back of your mind ?
User profile properties , yes that is what strikes us, and how to do we manage them. In simple word , its the same way as are all other data handled, the lists.
How do we synchronize the user profile properties ?
Some synchronization services indeed , see how simple and logical it is organized.

So maintain correct mapping and run the synchronization service and your results start getting fetched.




How do you Test a database split

What is a database split ?
When do we really come across with such a business scenario in our enterprise business ?
What is it that holds paramount importance in planning and strategizing the testing activities in such an application ?
How does the test related timelines impact the overall estimation in such a project ?
What are the areas of scope which have scope of optimization in test estimation of such project ?

I hope this post is best suited for your expectation to be met in case these are the areas of your interest when browsing through this post .

Database split is nothing but separation of a single entity into two child entities just the similar way an amoeba fission is known to occur. Here in the risk involved may be as high as ad infinitum in case there is some legal aspects involved .
So the best approach to test is validate the data that has been entered in the child databases. Only relevant data should get loaded into each of the respective sinister databases.
Bring in the approach of database test automation for validation of data content using the rowcount and datacheck as we discussed in a previous article listed as under.

http://www.articlesontesting.com/2012/06/etl-testing-in-business-intelligence.html

By following the approach mentioned in this article you can reduce heavily in test execution timelines. Scripting of the queries is a one time activity and you can use it in all subsequent cycles. Also the script preparation is a parallel activity and can be done during the course of development pahse itself. there is no need to maintain any test case document as well as the dbunit test scripts are themselves self explanatory. however in some cases depending on customer's expectation, some comments in the dbunits test script itslef can be provided.
Do you know how long it takes for the scripts to run ?
One script runs in times of milliseconds.
I ran close to ten databases split operation testing in five minutes and results were logged into TFS.
This included close to 450 tables validation with close to query counts in the range of 1275 odd !!!
And all was done in minutes. However you would have taken close to four man days for validation of tables to extent of these by manually executing these queries in sql management studio.

Enjoy smart test execution technique by implementing the dbunit test of visual studio 2010, while in 2012 version has been separately labelled as SqlDatabaseUnit test and you need to install the SSDT along with the Visual Studio 2012 IDE.

You will really have a ease of time handling this project, but without this approach the time taken for verification is just way high and not a feasible approach in the current trending industry.

Do post your queries and I shall help you get them answered herein asap.

AJAX Tab container control: For displaying content in tab style

A very common scenario  in web disign is to display two or more form in tab format.
Means instead of filling one form completely and then proceeding to next form we can access multiple form at a time using 
AJAX Tab container control.
We need to write below code.

  
ASPX page:

  <asp:TabContainer ID="tabCont" runat="server" ActiveTabIndex="0" Width="100%"  AutoPostBack="true"
                onactivetabchanged="tabCont_ActiveTabChanged" >
              <asp:TabPanel ID="tab1" runat="server"  HeaderText="General Details">
                <ContentTemplate>
                                   ..........
                 </ContentTemplate>
              </asp:TabPanel>
              <asp:TabPanel ID="tab2" runat="server" HeaderText="EmployerDetails" >
                <ContentTemplate>
                                     ..................
                 </ContentTemplate>
              </asp:TabPanel>
  </asp:TabContainer>


ASPX.CS page:

  protected void tabCont_ActiveTabChanged(object sender, EventArgs e)
      {
          if (tabCont.ActiveTab.HeaderText == "General Details")
          {                    
              tabCont.ActiveTabIndex = 0;
          }
          else if (tabCont.ActiveTab.HeaderText == "EmployerDetails")
           {
          tabCont.ActiveTabIndex = 1;
           }
      }

Dynamically adjust the size of a drop-down list in c# .net using javascript


A very common scenario  in C# programming for web controls we come across is the topic of description in this article. 
How do I dynamically adjust the size of a dropdown list using Javascript ?

There are many possible ways to visualie a working solution for the same but let us go through the one I prefer the most.

First we will try the use of “oncontextmenu”, this event gets fired when the we click on the control. Once we click the control, we invoke a Javascript function to increase the width of the drop-down list. If the width is initially less, then we increase it to the maximum. If the width is currently maximum, then or right-click we need to again resize the control .

<html xmlns="http://www.w3.org/1999/xhtml">
  <head id="Head1" runat="server">
  <title>Dynamic Size of ddl</title> 
 <script type="text/javascript"> 
function fnSize(ddlobj)
 { 
 if(ddlobj.style.width != "100px")  
{
ddlobj .style.width = "100"
 }
 else 
{
 ddlobj.style.width = "50"
 }
 } 
 </script>
  </head> 
 <body> 
 <form id="form1" runat="server">
<asp:DropDownList  id="ddlSize" runat="server" oncontextmenu="fnSize(this);"></asp:DropDownList>
 </form>
  </body> 
 </html>

 Above mentioned function will increase or decrease the width of ddl but size will be static, means not dependent on the listitem while binding dynamically from datatable or any other datasource. 

So, we will replace the above mentioned method as follows:

The select object has many events. we will use onmouseover,onblur and onchange.
 
onchange event is fired when the contents are committed(object or selection have changed.) and not while the value is changing. This event is executed before the code specified by onblur when the control is also losing the focus.The onchange event does not fire when the selected option of the select object is changed programmatically.

onmouseover event fires only if the mouse pointer is outside the boundaries of the object and the user moves the mouse pointer inside the boundaries of the object. If the mouse pointer is currently inside the boundaries of the object, for the event to fire, the user must move the mouse pointer outside the boundaries of the object and then back inside the boundaries of the object.


The onblur event fires on the original object before the onfocus or onclick event fires on the object that is receiving focus.

on these three events we will call our function to manipulate the size of dropdownlist dynamically.

<html xmlns="http://www.w3.org/1999/xhtml">
 <head id="Head1" runat="server">
  <title>Dynamic Size of ddl</title> 
 <script type="text/javascript">
 var spacer = null;
        var curObj = null;
        function openSize(obj) {
            if (spacer) return;
            spacer = document.createElement("span");
            spacer.style.width = obj.offsetWidth;
            spacer.style.height = obj.offsetHeight;
            spacer.style.display = "none";
            obj.parentNode.insertBefore(spacer, obj);
            obj.style.left = getSize(obj, "Left");
            obj.style.top = getSize(obj, "Top");
            obj.style.position = "absolute";
            obj.style.width = obj.scrollWidth;
            obj.focus();
            spacer.style.display = "inline";
            curObj = obj;
        }
        function close() {
            if (spacer) {
                spacer.parentNode.removeChild(spacer);
                spacer = null;
            }
            if (curObj) {
                curObj.style.width = "100px";
                curObj.style.position = "static";
            }
        }
        function getSize(o, p) {
            var i = 0; while (o != null)
            { i += o["offset" + p]; o = o.offsetParent; }
            return (i + 4);
        }
 </script>
  </head>
 <body>
 <form id="form1" runat="server">

  <asp:DropDownList ID="ddlSize" runat="server"  onmouseenter="openSize(this)"
                                onchange="close()" onblur="close()">    </asp:DropDownList>

 </form>
  </body>
 </html>
 

 Using above code, we can adjust size of drop down list at the time of selection dynamically.
Enjoy learning !!!

Default button in asp.net with master page

One of the most important thing in developing web pages is handling the "Enter key" for form submission or making the button which we provide Button to click on as default button, there are many easiest ways but sometime its becomes a little tricky using master page with button in panel.
ASP.NET introduces "defaultbutton" property to the ID of the Button, whose event we want to fire, our job is done. By using this property we can make our button as default button.
In page load we need to just write the below code:

 protected void Page_Load(object sender, EventArgs e)
    {

         this.Page.Form.DefaultButton = yourbuttonid.UniqueID;
    }