Please make a list of all the different types of testing a tester can do.

I like this question b/c then candidates have all these categories at the top of their heads for use in testing questions later in the day.

There are different names for the same kinds of testing, so candidates may use different terms. If you’re not sure, ask them to clarify.

A good answer will include many of the following: (the farther down on the list, the more likely a candidate will miss it)

· Black box – testing without knowing how the code works

· White box – testing when you know exactly what the code is doing

· Gray box – a combination of black and white box

· Automation – using code to create test cases that can be run over and over at the click of a mouse

· Functionality – the basic functional aspects. Ex can you print, save?

· UI (User Interface) –Do buttons and links take you to the right place? Can you find your way around?

· Error handling – if you make a mistake or do something evil, does the product recover gracefully?

· Performance – how fast does the product run under certain conditions?

· Stress – how does the software do when you put stress on it? Heavy loads, fewer resources like memory…

· Stability – how does the software do over time? When it’s been running for days on end?

· Load – how does the software do when lots of people are using it at once?

· Database – is the data getting to and from the database correctly?

· End to End/Integration – testing the code as a full system, rather than testing individual parts

· Component testing – testing the individual parts

· Usability – is the software intuitive to use? Watch actual customers use the product

· Boundary – if a field can take up to 10 characters, test 8, 9 and 10 chars.

· Scalability – can we grow this software to run on more servers and have more customers in the future?

· BVT (Build Verification Test) – basic cases run each time a new build is released)

· API (Application Program Interface) – testing the input/output for an OS service

· Bug Bash – let the whole team (PM, dev, marketing etc) test the product

· Alpha/Beta – let the customers test the product, get their feedback

· Regression – is a bug really fixed? Was anything else broken as a side effect of the fix?

· Compatibility – can the software run on different browsers and operating systems? Backward compatibility for Office and Windows? Upgrades?

· Security – is the software vulnerable to attacks?

· Globalization – is the software world-ready? (ex no hard coded strings)

· Localization – did we break anything when we regionalized the product?

Advertisements

Common Regular expression Patterns

You need a quick list from which to choose regular expression patterns that match
standard items. These standard items could be a social security number, a zip code, a
word containing only characters, an alphanumeric word, an email address, a URL,
dates, or one of many other possible items used throughout business applications.
These patterns can be useful in making sure that a user has input the correct data
and that it is well formed. These patterns can also be used as an extra security measure
to keep hackers from attempting to break your code by entering strange or malformed
input (e.g., SQL injection or cross-site-scripting attacks). Note that these
regular expressions are not a silver bullet that will stop all attacks on your system;
rather, they are an added layer of defense.

• Match only alphanumeric charactersalong with the characters–, +, ., and any
whitespace, with the stipulation that there is at least one of these characters and
no more than 10 of these characters:
^([\w\.+–]|\s){1,10}$
• Match a person’s name, up to 55 characters:
^[a-zA-Z\’\-\s]{1,55}$
• Match a positive or negative integer:
^(\+|\–)?\d+$
• Match a positive or negative floating point number only; this pattern does not
match integers:
^(\+|\–)?(\d*\.\d+)$
Match a floating point or integer number that can have a positive or negative
value:
^(\+|\–)?(\d*\.)?\d+$
• Match a date in the form ##/##/####, where the day and month can be a
one- or two-digit value and the year can only be a four-digit value:
^\d{1,2}\/\d{1,2}\/\d{4}$
• Match a time to be entered in the form ##:## with an optional am or pm extension
(note that this regular expression also handles military time):
^\d{1,2}:\d{2}\s?([ap]m)?$
• Verify if the input is a social security number of the form ###-##-####:
^\d{3}-\d{2}-\d{4}$
• Match an IPv4 address:
^([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9]$
• Verify that an email address is in the form name@address where address isnot an
IP address:
^[A-Za-z0-9_\-\.]+@(([A-Za-z0-9\-])+\.)+([A-Za-z\-])+$
Using Common Patterns | 391
• Verify that an email address is in the form name@address where address isan IP
address:
^[A-Za-z0-9_\-\.]+@([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9]$
• Match or verify a URL that uses either the HTTP, HTTPS, or FTP protocol.
Note that this regular expression will not match relative URLs:
^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-
9\-\._\?\,\’/\\\+&%\$#\=~])*$
• Match only a dollar amount with the optional $ and + or -preceding characters
(note that any number of decimal places may be added):
^\$?[+-]?[\d,]*(\.\d*)?$
This is similar to the previous regular expression, except that no more than two
decimal places are allowed:
^\$?[+-]?[\d,]*\.?\d{0,2}$
• Match a credit card number to be entered as four sets of four digits separated
with a space, -, or no character at all:
^((\d{4}[- ]?){3}\d{4})$
• Match a zip code to be entered asfive digitswith an optional four-digit extension:
^\d{5}(-\d{4})?$
• Match a North American phone number with an optional area code and an
optional – character to be used in the phone number and no extension:
^(\(?[0-9]{3}\)?)?\-?[0-9]{3}\-?[0-9]{4}$
• Match a phone number similar to the previous regular expression but allow an
optional five-digit extension prefixed with either ext or extension:
^(\(?[0-9]{3}\)?)?\-?[0-9]{3}\-?[0-9]{4}(\s*ext(ension)?[0-9]{5})?$
• Match a full path beginning with the drive letter and optionally match a filename
with a three-character extension (note that no .. characters signifying to
move up the directory hierarchy are allowed, nor isa directory name with a . followed
by an extension):
^[a-zA-Z]:[\\/]([_a-zA-Z0-9]+[\\/]?)*([_a-zA-Z0-9]+\.[_a-zA-Z0-9]{0,3})?$
• Verify if the input password string matches some specific rules for entering a
password (i.e., the password is between 6 and 25 characters in length and contains
alphanumeric characters):
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,25}$
• Determine if any maliciouscharacterswere input by the user. Note that thisregular
expression will not prevent all malicious input, and it also prevents some
valid input, such as last names that contain a single quote:
^([^\)\(\<\>\”\’\%\&\+\;][(-{2})])*$
• Extract a tag from an XHTML, HTML, or XML string. This regular expression
will return the beginning tag and ending tag, including any attributesof the tag.

Note that you will need to replace TAGNAME with the real tag name you want
to search for:
<TAGNAME.*?>(.*?)</TAGNAME>
• Extract a comment line from code. The following regular expression extracts
HTML commentsfrom a web page. Thiscan be useful in determining if any
HTML comments that are leaking sensitive information need to be removed
from your code base before it goes into production:
<!–.*?–>
• Match a C# single line comment:
//.*$
• Match a C# multiline comment:
/\*.*?\*/

Technical Questions

1) Which is better – singly linked list or doubly linked list? What are the pros and cons of using each?
Singly linked list has smaller memory requirement because singly linked list can only be traversed in one direction. Doubly linked lists require more space for each element in the list and elementary operations such as insertion and deletion is more complex since they have to deal with two references. But doubly link lists allow easier manipulation since it allows traversing the list in forward and backward directions.

Singly Linked List vs. Doubly Linked List

· Elements in singly linked list are linked to only the next element in the series while elements are linked with previous and next both elements in doubly linked list.

· Singly linked lists need lesser space while doubly linked list need more space for every block in the list.

· Basic functions like addition or deletion are complicated in doubly linked list because there are two links to deal with but you can easily manipulate the data because you can cross over the list and move back and forth in the list.

2) What’s the difference between Managed code and Native code? Give examples of each you have worked on.

Managed Code:

Managed code runs on the CLR (Common Language Runtime), which, among other things, offers services like garbage collection, run-time type checking, and reference checking. Managed code takes advantages of memory management, security and threading services CLR provides.

The managed code is the one generated by C# and other .NET language compilers (IL) and gets finally converted to native code by JIT. If you are writing an application in Visual C++ .NET you can produce managed code if you like, but it’s optional.

Native Code:

Native code does not run under CLR and compiles straight to machine code. No free memory management or anything else the CLR provides. Since you cannot create unmanaged code with Visual Basic or C#, in Visual Studio all unmanaged code is written in C/C++.

I wrote some web applications in C and C++ on the apache on Linux. These are native code applications whose memory is not “managed”, as in, memory isn’t freed (C++’ delete and C’s free, for instance), no reference counting, no garbage collection. I had to take care of these to free allocated memory.

3) What is thread safe code? Give an example of times you’ve used thread safe code.

Thread Safe code is one which runs in a manner that when multiple threads are running simultaneously and are in need of using shared memory, they do not step onto each other or in other words access the shared memory exclusively.

By using thread-safe routines, the risk that one thread will interfere and modify data elements of another thread is eliminated by circumventing potential data race situations with coordinated access to shared data.

Implement a circular queue

Implement a circular queue of integers of user-specified size using a simple array. Provide routines to initialize(), enqueue() and dequeue() the queue. Make it thread safe.

   1: using System;

   2: using System.Text;

   3: using System.Threading;

   4:  

   5: public class IntegerQueue

   6: {

   7:     int[] _queue;

   8:     int _in;

   9:     int _out;

  10:     int _count;

  11:  

  12:     private static Object QueueLock = new Object(); // Make the Queue thread safe

  13:  

  14:     public IntegerQueue(int size)

  15:     {

  16:         Initialize(size);

  17:     }

  18:  

  19:     public void Initialize(int size)

  20:     {

  21:         _queue = new int[size];

  22:         _count = 0;

  23:         _in = 0;

  24:         _out = 0;

  25:     }

  26:  

  27:     public void Enqueue(int value)

  28:     {

  29:         lock (QueueLock)

  30:         {

  31:             Console.WriteLine("Enqueue: {0}", value);

  32:             if (_queue.Length <= _count)

  33:             {

  34:                 Console.WriteLine("Overflow.");

  35:             }

  36:             else

  37:             {

  38:                 _queue[_in] = value;

  39:                 _in = (_in + 1) % _queue.Length;

  40:                 _count++;

  41:             }

  42:             DebugPrint();

  43:         }

  44:     }

  45:     public int Dequeue()

  46:     {

  47:         lock (QueueLock)

  48:         {

  49:             Console.WriteLine("Dequeue:");

  50:             int value = 0;

  51:             if (_count <= 0)

  52:             {

  53:                 Console.WriteLine("Underflow.");

  54:             }

  55:             else

  56:             {

  57:                 value = _queue[_out];

  58:                 _out = (_out + 1) % _queue.Length;

  59:                 _count--;

  60:             }

  61:             DebugPrint();

  62:             return value;

  63:         }

  64:  

  65:     }

  66:     public override String ToString()

  67:     {

  68:         StringBuilder builder = new StringBuilder();

  69:         if (_count > 0)

  70:         {

  71:             for (int i = 0; i < _count; i++)

  72:             {

  73:                 builder.Append(_queue[(_out + i) % _queue.Length]);

  74:                 builder.Append(", ");

  75:             }

  76:         }

  77:         else

  78:         {

  79:             builder.Append("(empty)");

  80:         }

  81:         return builder.ToString();

  82:     }

  83:     public void DebugPrint()

  84:     {

  85:  

  86:         lock (QueueLock)

  87:         {

  88:             Console.WriteLine("\t{0}", ToString());

  89:         }

  90:  

  91:     }

  92:  

  93:  

  94:     public void QueueTest()

  95:     {

  96:         Enqueue(1);

  97:         Console.WriteLine();

  98:  

  99:         Enqueue(2);

 100:         Console.WriteLine();

 101:  

 102:        Enqueue(3);

 103:         Console.WriteLine();

 104:  

 105:         Console.WriteLine("--> {0}", Dequeue());

 106:         Console.WriteLine();

 107:  

 108:         Console.WriteLine("--> {0}", Dequeue());

 109:         Console.WriteLine();

 110:  

 111:         Console.WriteLine("--> {0}", Dequeue());

 112:         Console.WriteLine();

 113:  

 114:         Enqueue(4);

 115:         Console.WriteLine();

 116:  

 117:         Enqueue(5);

 118:         Console.WriteLine();

 119:  

 120:         Console.WriteLine("--> {0}", Dequeue());

 121:         Console.WriteLine();

 122:  

 123:         Enqueue(6);

 124:         Console.WriteLine();

 125:  

 126:         Enqueue(7);

 127:         Console.WriteLine();

 128:  

 129:         Enqueue(8);

 130:         Console.WriteLine();

 131:  

 132:         Enqueue(9);

 133:         Console.WriteLine();

 134:  

 135:         Console.WriteLine("--> {0}", Dequeue());

 136:         Console.WriteLine();

 137:  

 138:         Console.WriteLine("--> {0}", Dequeue());

 139:         Console.WriteLine();

 140:  

 141:         Console.WriteLine("--> {0}", Dequeue());

 142:         Console.WriteLine();

 143:  

 144:         Console.WriteLine("--> {0}", Dequeue());

 145:         Console.WriteLine();

 146:  

 147:         Console.WriteLine("--> {0}", Dequeue());

 148:         Console.WriteLine();

 149:  

 150:         Console.ReadLine();

 151:     }

 152:  

 153: }

 154:  

 155: public class QueueApp

 156: {

 157:     public static void Main(String[] args)

 158:     {

 159:         IntegerQueue queue = new IntegerQueue(5);

 160:  

 161:         Thread[] threads = new Thread[1];

 162:  

 163:         for (int i = 0; i < threads.Length; i++)

 164:         {

 165:             threads[i] = new Thread(new ThreadStart(queue.QueueTest));

 166:         }

 167:  

 168:         for (int i = 0; i < threads.Length; i++)

 169:         {

 170:             threads[i].Start();

 171:         }

 172:         Console.ReadLine();

 173:     }

 174: }

Triangle check

Write me a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error). Generate test cases for the function assuming another developer coded the function

 

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Text;

   5:  

   6: namespace Triangle

   7: {

   8:     class Program

   9:     {

  10:         public enum TriangleType

  11:         {

  12:             Scalene = 1,

  13:             Isosceles = 2,

  14:             Equilateral = 3,

  15:             Error = 4,

  16:         }

  17:         private static TriangleType triangle(int a, int b, int c)

  18:         {

  19:             TriangleType answer;

  20:  

  21:             if (a <= 0 || b <= 0 || c <= 0)

  22:             {

  23:                 // negative length -- illegal

  24:                 answer =  TriangleType.Error;

  25:             }

  26:             else if ((a + b <= c) || (b + c <= a) || (a + c <= b))

  27:             {

  28:                 // Sides can't possible connect -- illegal

  29:                 answer = TriangleType.Error;

  30:             }

  31:             else if ((a == b) && (b == c))

  32:             {

  33:                 // by the transitive rule, a == c well

  34:                 answer = TriangleType.Equilateral;

  35:             }

  36:             else if ((a == b) || (b == c) || (a == c))

  37:             {

  38:                 // We've already eliminated quilateral triangles above,

  39:                 // we'll only get here if exactly two sides match

  40:                 answer = TriangleType.Isosceles;

  41:             }

  42:             else

  43:             {

  44:                 // Since, we've eliminated all alternatives, we must have

  45:                 // a scalene triangle if we get here.

  46:                 answer = TriangleType.Scalene;

  47:             }

  48:  

  49:             return answer;

  50:         }

  51:  

  52:         static void Main(string[] args)

  53:         {

  54:             TriangleType result;

  55:             result = triangle(0, 0, 0);

  56:             Console.WriteLine("(0, 0, 0) = {0}", result.ToString());

  57:  

  58:             result = triangle(-1, 2, 3);

  59:             Console.WriteLine("(-1, 2, 3) = {0}", result.ToString());

  60:  

  61:             result = triangle(1, -2, 3);

  62:             Console.WriteLine("(1, -2, 3) = {0}", result.ToString());

  63:  

  64:             result = triangle(1, 2, -3);

  65:             Console.WriteLine("(1, 2, -3) = {0}", result.ToString());

  66:  

  67:             result = triangle(1, 1, 1);

  68:             Console.WriteLine("(1, 1, 1) = {0}", result.ToString());

  69:  

  70:             result = triangle(1, 2, 2);

  71:             Console.WriteLine("(1, 2, 2) = {0}", result.ToString());

  72:  

  73:             result = triangle(4, 5, 6);

  74:             Console.WriteLine("(4, 5, 6) = {0}", result.ToString());

  75:  

  76:             result = triangle(5, 1, 5);

  77:             Console.WriteLine("(5, 1, 5) = {0}", result.ToString());

  78:  

  79:             result = triangle(5, 5, 5);

  80:             Console.WriteLine("(5, 5, 5) = {0}", result.ToString());

  81:  

  82:             result = triangle(-10, -10, -10);

  83:             Console.WriteLine("(-10, -10, -10) = {0}", result.ToString());

  84:         }

  85:     }

  86: }