Mobile game test cases

1. Check for background music and sound effects
– ON/OFF sound & background music check
– Put the device into sleep mode n check
– Receive the call and check
– Verify if sound effects are in sync with action
– ON/OFF device sound(native sound) and check
– Check for vibration effect if present

2. UI
– Check in Landscape/Portrait mode
– Check for animation, movement of character, graphics, Zoom In/Out (all gestures) etc
– There should not be any clipping
– Test when one object overlaps with another
– Verify if loading indicator is displayed wherever required
– Character should not move out of the screen/specified area
– Test for enable and disable images/icons/buttons etc
– Check for screen title
– Check for message title, message description, label (should be appropriate)
– Check scrolling
– Font
– Check other objects too (ex -if its a car race- you need to look at road, people, other objects like buildings etc)

3. Performance (imp)
– Check the loading time of a game
– Make sure that any action is not taking considerable time, game flow should be fast

4. Score
– score calculation
– Verify leaderboards General/All time/Weekly/local etc
– Check the score registration functionality
– Check the format (whether, coma is required in score etc ideally if customer is a foriegner coma should be in millions not in thousands )
– Check for level completion syncs with the score

5. Time Out
– check for time out
– Do the actions when time-out yet to happen

6. Multitasking
– Switch b/w different apps and play game , check for
sound, score, UI, time-out etc

7. Pause
– Check if game is paused when call received or multitasking or sleep mode

8. Save Settings
– Turnoff and ON device, check if settings are saved
– Log out /On , check same
– User should not loose his game in above conditions

9. User profile
– Put a all types of images in Player profile n check
– Put special character, numbers,space in username and check
– Password should be in masked

10. Push notifications

11. Chat feature
– Check the profile images
– max limit of chat description
– Enter empty string, special character and check
– For a opponent , there should be a notification that he has received a message

13. Functionality
– Check game area, game logic
– play till last level
– get the cheat codes from development team and check all the levels
– Check for the features that will be unlocked level-wise
– Check for bonus score
– Check the score hike when level gets increased
– Check for multi-tap action (example in a car race we hold accelerator and left/right turn button simultaneously)
– Menu options
– Different game modes/location

14. Help & About Screen
– its must
– Should be in easily understandable format
– free from spelling mistakes
– URL should be hyperlinked (depends)

15. Multiplayer game
– Session expiry check
– login/log out
– Registration (Sign Up)
– Verify account (receive verification mail)
– login with registered but not verified account (without clicking verification link)
– Forgot password checks (many cases here)
– Game flow
– Check for WIN/lost/Draw
– Check user statistics graph 

– Challenge/Decline challenge/receive challenge
– Check for forfeit
– Check when player 2’s turn is on Player 1 is not able to do actions (should not be able to forfeit also)
– Check for pass turn
– Check for time-out (for one player)
– Check the score for both the players till game ends

16. Memory leak
– Check the game when device memory is low

17. N/w check
– N/w messages if n/w is not present
– check if what happens when n/w not present and user plays a move (whether score submitted for that move etc)

18. Check for localization (Support of different languages)

19. Check for time format
– Change the device time , format etc

20. Size
– User wont like if your game takes lot of device space, so keep one eye on game file size

21. Device , OS
– Check in supported screen sizes and os versions

22. Depends on platform
– Sometime we need to check as per os guidliness as well. For ex in Wp7
we need to check in 2 background (light/dark).

23. Check Share options
– Post score via mail/FB/Twitter
– Check the posted/sent messages in FB/Twitter/Mail. Check links are hyperlinked and application icon is displayed in the post (depends)
– If twitter integration is a manual ( custom UI developed by developer), check what happens when u enter more than 140 chars (as twitter limit is 140)

Advertisements

Implement IndexOf method without Framework

Array.IndexOf searches an array. It acts upon an array of any type in the C# language. It locates the offset of the value searched for. The IndexOf method on Array, in both its generic form and its LastIndexOf form, is useful in many program contexts.

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Text;

   5:  

   6: namespace IndexOF

   7: {

   8:     class Program

   9:     {

  10:  

  11:         private static int IndexOf(char[] chars1, char[] chars2)

  12:         {

  13:             if (chars1.Length < chars2.Length)

  14:                 return -1;

  15:  

  16:             int found = -1;

  17:             int j = 0;

  18:  

  19:             for (int i = 0; i < chars1.Length; i++)

  20:             {

  21:                 if (chars1[i] == chars2[j])

  22:                 {

  23:                     if (j == 0)

  24:                         found = i;

  25:  

  26:                     j++;

  27:                     if (j >= chars2.Length)

  28:                         return found;

  29:                 }

  30:                 else

  31:                 {

  32:                     j = 0;

  33:  

  34:                     if (found >= 0)

  35:                         i = found;

  36:                     found = -1;

  37:                 }

  38:             }

  39:             

  40:             return -1;

  41:         }

  42:  

  43:         static void Main(string[] args)

  44:         {

  45:             char[] arr1 = { 'v', 'a', 'b', 'c', 'd', 'e', 'f' };

  46:             char[] arr2 = { 'c', 'd', 'v'};

  47:  

  48:  

  49:             Console.WriteLine("index = {0}", IndexOf(arr1, arr2).ToString());

  50:  

  51:             Console.ReadKey();

  52:         }

  53:     }

  54: }

Coding Questions

Please answer one or both of the following questions. Please do not use existing class libraries in your answer(s):

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:  

   3: namespace CubicType

   4: {

   5:     class Program

   6:     {

   7:         public enum CubicType

   8:         {

   9:             Scalene = 1, // no sides same length

  10:             Isosceles = 2, // 2 sides same length

  11:             Equilateral = 3, // 3 sides same length

  12:             Error = 4,

  13:         }

  14:  

  15:         private static CubicType GetCubicType(int a, int b, int c) {

  16:             if (a <= 0 || b <= 0 || c <= 0) {

  17:                 return CubicType.Error;

  18:             }

  19:  

  20:             if ((a == b) && (b == c)) {

  21:                 return CubicType.Equilateral;

  22:             }

  23:  

  24:  

  25:             if ((a == b) || (a == c) || (b == c)) {

  26:                 return CubicType.Isosceles;

  27:             }

  28:  

  29:  

  30:             if (((a + b) < c) || ((a + c) < b) || ((b + c) < a)) {

  31:                 return CubicType.Error;

  32:             }

  33:             else {

  34:                 return CubicType.Scalene;

  35:             }

  36:  

  37:         }

  38:  

  39:         static void Main(string[] args) {

  40:  

  41:             CubicType result;

  42:  

  43:             /*

  44:              * Test cases

  45:              * 1. valid scalene triangle?

  46:              * 2. valid equilateral triangle?

  47:              * 3. valid isosceles triangle?

  48:              * 4. 3 permutations of previous?

  49:              * 5. side = 0?

  50:              * 6. negative side?

  51:              * 7. one side is sum of others (1, 2, 3)?

  52:              * 8. 3 permutations of previous?

  53:              * 9. one side larger than sum of others (1, 2, 4)?

  54:              * 10. 3 permutations of previous?

  55:              * 11. all sides = 0?

  56:              * 12. non-integer input?

  57:              * 13. wrong number of values?

  58:              * 14. for each test case: is expected output specified?

  59:              * 15. check behaviour after output was produced?

  60:              * 

  61:             */

  62:             result = GetCubicType(1, 1, 1);

  63:             Console.WriteLine("(1, 1, 1) = {0}", result.ToString()); // Equilateral triangle

  64:  

  65:             result = GetCubicType(2, 1, 1);

  66:             Console.WriteLine("(2, 1, 1) = {0}", result.ToString()); // Isosceles triangle

  67:  

  68:             result = GetCubicType(1, 2, 1);

  69:             Console.WriteLine("(1, 2, 1) = {0}", result.ToString()); // Isosceles triangle

  70:  

  71:             result = GetCubicType(1, 1, 2);

  72:             Console.WriteLine("(1, 1, 2) = {0}", result.ToString()); // Isosceles triangle

  73:                        

  74:             

  75:             result = GetCubicType(1, 2, 25);

  76:             Console.WriteLine("(1, 2, 25) = {0}", result.ToString()); // Error

  77:  

  78:             result = GetCubicType(1, 0, -1);

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

  80:  

  81:             result = GetCubicType(4, 5, 6);

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

  83:             

  84:             result = GetCubicType(2147483647, 2147483647, 2147483647);

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

  86:  

  87:         }

  88:     }

  89: }

 

1) 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.Collections.Generic;

   3: using System.Linq;

   4: using System.Text;

   5: using System.Threading;

   6:  

   7: namespace ThreadSafeCircularQueue

   8: {

   9:     /// <summary>

  10:     ///  CircularQueue

  11:     /// </summary>

  12:     public class CircularQueue

  13:     {

  14:         private int head;

  15:         private int tail;

  16:         private int[] queue;

  17:         private int length;

  18:  

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

  20:  

  21:         /// <summary>

  22:         ///  Queue Constructor

  23:         /// </summary>

  24:         /// <param name="lengh"> Length of Queue</param>

  25:         public CircularQueue(int lengh)

  26:         {

  27:             Initialize(length);

  28:         }

  29:  

  30:         public CircularQueue()

  31:         {

  32:  

  33:         }

  34:  

  35:         /// <summary>

  36:         /// Initializes the Queue

  37:         /// </summary>

  38:         /// <param name="length"> length </param>

  39:         private void Initialize(int length)

  40:         {

  41:             head = -1;

  42:             tail = -1;

  43:  

  44:             this.length = length;

  45:             queue = new int[length];

  46:  

  47:             Console.WriteLine("Queue size: {0}", length);

  48:         }

  49:  

  50:         /// <summary>

  51:         /// Adds a new int element to the tail of the Queue

  52:         /// </summary>

  53:         /// <param name="value">The integer value of the element to be queued</param>

  54:         /// <returns>The index of the queued element or failure</returns>

  55:         public int Enqueue(int value)

  56:         {

  57:             lock (QueueLock) {

  58:                 if ((head == 0 && tail == length - 1) || (tail + 1 == head)) {

  59:                     Console.WriteLine("Queue is full.");

  60:                     return -1;

  61:                 }

  62:                 else {

  63:                     if (tail == length - 1)

  64:                         tail = 0;

  65:                     else

  66:                         tail++;

  67:  

  68:                     queue[tail] = value;

  69:  

  70:                     if (head == -1)

  71:                         head = 0;

  72:  

  73:                     return tail;

  74:                 }

  75:  

  76:             }

  77:         }

  78:  

  79:         /// <summary>

  80:         /// Gets the first element's value

  81:         /// </summary>

  82:         /// <returns></returns>

  83:         public int Dequeue()

  84:         {

  85:             lock (QueueLock) {

  86:                 int value;

  87:  

  88:                 if (head == -1) {

  89:                     value = -1;

  90:                 }

  91:                 else {

  92:                     value = queue[head];

  93:                     queue[head] = 0;

  94:  

  95:                     if (head == tail)

  96:                         head = tail = -1;

  97:                     else

  98:                         if (head == length - 1)

  99:                             head = 0;

 100:                         else

 101:                             head++;

 102:                 }

 103:  

 104:                 return value;

 105:             }

 106:         }

 107:  

 108:         /// <summary>

 109:         /// Gets a formatted string of the queue elements

 110:         /// </summary>

 111:         /// <returns>Queue elements</returns>

 112:         public string ShowQueue()

 113:         {

 114:             lock (QueueLock) {

 115:                 int i;

 116:                 string result = " Queue Emelemnts: ";

 117:  

 118:                 if (head == -1) {

 119:                     result = "No elements(empty)";

 120:                 }

 121:                 else {

 122:                     if (tail < head) {

 123:                         for (i = 0; i <= length - 1; i++)

 124:                             result += queue[i] + " ";

 125:                     }

 126:                     else

 127:                         for (i = 0; i <= tail; i++)

 128:                             result += queue[i] + " ";

 129:                 }

 130:                 return result + "\n";

 131:             }

 132:         }

 133:  

 134:         /// <summary>

 135:         /// Test

 136:         /// </summary>

 137:         public void QueueTest()

 138:         {

 139:             Initialize(3);

 140:             Enqueue(1);

 141:             Console.Write(ShowQueue());

 142:             Enqueue(2);

 143:             Console.Write(ShowQueue());

 144:             Enqueue(3);

 145:             Console.Write(ShowQueue());

 146:             Enqueue(4);

 147:             Console.Write(ShowQueue()); 

 148:             Dequeue();

 149:             Console.Write(ShowQueue());

 150:             Dequeue();

 151:             Console.Write(ShowQueue());

 152:             Dequeue();

 153:             Console.Write(ShowQueue());

 154:             Dequeue();

 155:             Console.Write(ShowQueue());

 156:             Enqueue(4);

 157:             Console.Write(ShowQueue());

 158:             Dequeue();

 159:             Console.Write(ShowQueue());

 160:             Dequeue();

 161:             Console.Write(ShowQueue());

 162:         }

 163:  

 164:     }

 165:  

 166:     class Program

 167:     {

 168:         static void Main(string[] args)

 169:         {

 170:             CircularQueue circularQueue = new CircularQueue();

 171:  

 172:             Thread[] threads = new Thread[5];

 173:  

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

 175:                 threads[i] = new Thread(new ThreadStart(circularQueue.QueueTest));

 176:             }

 177:  

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

 179:                 threads[i].Start();

 180:             }

 181:             Console.ReadLine();

 182:         }

 183:     }

 184: }

Technical Questions 1

1) Which is better – singly linked list or doubly linked list? What are the pros and cons of using each?

Singly-linked list:

Pros: Simple in implementation, requires relatively lesser memory for storage, assuming you need to insert/delete at next node; insertion/deletion is faster.

Cons: Cannot be iterated in reverse, need to maintain a handle to the head node of the list else, the list will be lost in memory. If you’re deleting previous node or inserting at previous node, you will need to traverse list from head to previous node to be able to carry out those operations – O(N) time.

That should be used when you have lesser memory and your main purpose is insertion/deletion and not searching elements.

Doubly-linked list:

Pros: Can be iterated in forward as well as reverse direction. In case of needing to delete previous node, there is no need to traverse from head node, as the node to be deleted can be found from ‘.previous’ pointer.

Cons: Relatively complex to implement, requires more memory for storage (1 ‘.previous’ pointer per node). Insertions and deletions are relatively more time consuming (assigning/reassigning ‘.previous’ pointer for neighbor nodes)

That should be used when you have no minimal limitations on memory, and your main purpose is to search for elements.

2) What’s the difference between Managed code and Native code? Give examples of each you have worked on.
The big difference is memory management. With Native Code, you need to do your own resource (RAM / Memory) allocation and cleanup. If you forget something, you end up with what’s called a “Memory Leak” that can crash the computer. A Memory Leak is a term for when an application starts using up (eating up) Ram/Memory but not letting it go so the computer can use if for other applications; eventually this causes the computer to crash. With Managed Code, all the resource (RAM / Memory) allocation and cleanup are done for you and the risk of creating “Memory Leaks” is reduced to a minimum. This allows more time to code features instead of spending it on resource management.

  • · Managed code runs under CLR whereas native code does not run under CLR.
  • · Managed code takes advantages of memory management, security and threading services CLR provides, whereas these are missing for native code that directly runs on the machine.
  • · The managed code is the one generated by C# and other .NET language compilers (IL) and gets finally converted to native code by JIT. The code in languages prior to .NET like VC++ get converted directly to native code and runs on the machine.eg COM components

Over the past two years, I developed web applications for extending the server by modules which are developed in two ways (We have specific requirements that demand native code development and would like to convert our existing native ISAPI components, take advantage of this API to build server components.):

a) Using managed code, and the ASP.NET server extensibility APIs

b) Using native code, and the IIS native server extensibility APIs

3) What is thread safe code? Give an example of times you’ve used thread safe code.
Thread-safety is a computer programming concept applicable to multi-threaded programs. A piece of code is thread-safe if it is reentrant or protected from multiple simultaneous executions by some form of mutual exclusion.

Thread-safety is a key challenge in multi-threaded programming. In a multi-threaded program, several threads execute simultaneously in a shared address space. Every thread has access to virtually all the memory of every other thread. Thus the flow of control and the sequence of accesses to data often have little relation to what would be reasonably expected by looking at the text of the program. This violates the principle of least astonishment. Thread-safety is a property aimed for so as to minimize surprising behavior by re-establishing some of the correspondences between the actual flow of control and the text of the program.

General-purpose types are rarely thread-safe in their entirety, for the following reasons:

  • · The development burden in full thread safety can be significant, particularly if a type has many fields (each field is a potential for interaction in an arbitrarily multithreaded context).
  • · Thread safety can entail a performance cost (payable, in part, whether or not the type is actually used by multiple threads).
  • · A thread-safe type does not necessarily make the program using it thread-safe, and often the work involved in the latter makes the former redundant.

Example: Methods used in Logger, to write a log file, should be threading safe for an application that runs under multi-threading environment.

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

   1: public static class SharedLogger

   2: {

   3:     private static LogToFile _writer = new LogToFile();

   4:     private static object _lock = new object();

   5:     public static void Write(string text)

   6:     {

   7:         lock (_lock)

   8:         {

   9:             _writer.LogToFile(string text);

  10:         }

  11:     }

  12: }

Choosing Test Data

In system testing, test data should cover the possible values of each parameter based on the the requirements. Since testing every value is impractical, a few values should be chosen from each equivalence class. An equivalence class is a set of values that should all be treated the same.

Ideally, test cases that check error conditions are written separately from the functional test cases and should have steps to verify the error messages and logs. Realistically, if error test cases are not yet written, it is OK for testers to check for error conditions when performing normal functional test cases. It should be clear which test data, if any, is expected to trigger errors.

Example equivalence classes:

Strings

  • empty string
  • String consisting solely of white space
  • String with leading or trailing white space
  • syntactically legal: short and long values
  • syntactically legal: semantically legal and illegal values
  • syntactically illegal value: illegal characters or combinations
  • Make sure to test special characters such as #, “, ‘, &, and <
  • Make sure to test “Foreign” characters typed on international keyboards
Numbers

  • empty string, if possible
  • 0
  • in range positive, small and large
  • in range negative, small and large
  • out of range positive
  • out of range negative
  • with leading zeros
  • syntactically invalid (e.g., includes letters)
Identifiers

  • empty string
  • syntactically legal value
  • syntactically legal: reference to existing ID, invalid reference
  • syntactically illegal value
Radio buttons

  • one item checked
  • nothing checked, if possible
Checkboxes

  • checked
  • unchecked
Drop down menus

  • select each item in turn
Scrolling Lists

  • select no item, if possible
  • select each item in turn
  • select combinations of items, if possible
  • select all items, if possible
File upload

  • blank
  • 0 byte file
  • long file
  • short file name
  • long file name
  • syntactically illegal file name, if possible (e.g., “File With Spaces.tar.gz”)

Selected Software Engineering Books

Methodologies / Requirements
Testing / Quality
Web Services and .Net
Java (and other languages)
User Interfaces
General Textbooks on Software Engineering
Configuration Management
Design / UML
Open source tools
Web development
More Textbooks and Classics
Professional Development

Sample Security Test Cases For A Shopping Cart Application

Functional Tests
    * Customer Order File
      * Ensure that ‘orders.txt’ file permissions are as restrictive as possible. If these permissions are loosely defined then this as a severity 1 security issue.
      * Ensure that sensitive data within the ‘orders.txt’ file is encrypted using a known strong algorithm. This is a severity 1 security issue.
    * Customer Data Stored in a SQL Database
      * Ensure that sensitive data within the SQL Database is encrypted using a known strong algorithm. This is a severity 1 security issue.
    * Registration Form
      * For each user input perform common security related input validation tests. See The Web Application Security Consortium’s Threat Classification for a list of common input vulnerability types. For each input perform each vulnerability type. The severity level of a vulnerability will be determined by the vulnerability type, and probability.
      * (If SQL is Used) Perform both standard SQL Injection, and Blind SQL Injection tests as outlined by http://www.spidynamics.com/whitepapers/Blind_SQLInjection.pdf and http://www.securiteam.com/securityreviews/5DP0N1P76E.html. If SQL Injection is present file this as a severity 1 issue.
    * Login
      * For each user input perform common security related input validation tests. See The Web Application Security Consortium’s Threat Classification for a list of common input vulnerability types. For each input perform each vulnerability type. The severity level of a vulnerability will be determined by the vulnerability type, and probability.
      * (If SQL is Used) Perform both standard SQL Injection, and Blind SQL Injection tests as outlined by http://www.spidynamics.com/whitepapers/Blind_SQLInjection.pdf and http://www.securiteam.com/securityreviews/5DP0N1P76E.html. If SQL Injection is present file this as a severity 1 issue.
    * Buying Items
      * Ensure that the user is unable to modify the price for a given item. Ensure that the price is not exposed in a web form, cookie, query string, or POST data. If the price is exposed through one of these vectors ensure that if changed, the application detects the modification on the server side and refuses to sell the item for anything other than the stated price.
      * For each user input perform common security related input validation tests. See The Web Application Security Consortium’s Threat Classification for a list of common input vulnerability types. For each input perform each vulnerability type.
    * Search Engine
      * For each user input perform common security related input validation tests. See The Web Application Security Consortium’s Threat Classification for a list of common input vulnerability types. For each input perform each vulnerability type.
      * (If user text is echo’d back) Test for Cross site scripting vulnerabilities. If discovered file a severity 2 issue.

Web Testing: Complete guide on testing web applications

Here we will see some more details on web application testing with web testing test cases. Let me tell you one thing that I always like to share practical knowledge, which can be useful to users in their career life. This is a quite long article so sit back and get relaxed to get most out of it.

Let’s have first web testing checklist.
1) Functionality Testing
2) Usability testing
3) Interface testing
4) Compatibility testing
5) Performance testing
6) Security testing

1) Functionality Testing:

Test for – all the links in web pages, database connection, forms used in the web pages for submitting or getting information from user, Cookie testing.

Check all the links:

  • Test the outgoing links from all the pages from specific domain under test.
  • Test all internal links.
  • Test links jumping on the same pages.
  • Test links used to send the email to admin or other users from web pages.
  • Test to check if there are any orphan pages.
  • Lastly in link checking, check for broken links in all above-mentioned links.

Test forms in all pages:
Forms are the integral part of any web site. Forms are used to get information from users and to keep interaction with them. So what should be checked on these forms?

  • First check all the validations on each field.
  • Check for the default values of fields.
  • Wrong inputs to the fields in the forms.
  • Options to create forms if any, form delete, view or modify the forms.

Let’s take example of the search engine project currently I am working on, In this project we have advertiser and affiliate signup steps. Each sign up step is different but dependent on other steps. So sign up flow should get executed correctly. There are different field validations like email Ids, User financial info validations. All these validations should get checked in manual or automated web testing.

Cookies testing:
Cookies are small files stored on user machine. These are basically used to maintain the session mainly login sessions. Test the application by enabling or disabling the cookies in your browser options. Test if the cookies are encrypted before writing to user machine. If you are testing the session cookies (i.e. cookies expire after the sessions ends) check for login sessions and user stats after session end. Check effect on application security by deleting the cookies. (I will soon write separate article on cookie testing)

Validate your HTML/CSS:
If you are optimizing your site for Search engines then HTML/CSS validation is very important. Mainly validate the site for HTML syntax errors. Check if site is crawlable to different search engines.

Database testing:
Data consistency is very important in web application. Check for data integrity and errors while you edit, delete, modify the forms or do any DB related functionality.
Check if all the database queries are executing correctly, data is retrieved correctly and also updated correctly. More on database testing could be load on DB, we will address this in web load or performance testing below.

2) Usability Testing:

Test for navigation:
Navigation means how the user surfs the web pages, different controls like buttons, boxes or how user using the links on the pages to surf different pages.
Usability testing includes:
Web site should be easy to use. Instructions should be provided clearly. Check if the provided instructions are correct means whether they satisfy purpose.
Main menu should be provided on each page. It should be consistent.

Content checking:
Content should be logical and easy to understand. Check for spelling errors. Use of dark colors annoys users and should not be used in site theme. You can follow some standards that are used for web page and content building. These are common accepted standards like as I mentioned above about annoying colors, fonts, frames etc.
Content should be meaningful. All the anchor text links should be working properly. Images should be placed properly with proper sizes.
These are some basic standards that should be followed in web development. Your task is to validate all for UI testing

Other user information for user help:
Like search option, sitemap, help files etc. Sitemap should be present with all the links in web sites with proper tree view of navigation. Check for all links on the sitemap.
“Search in the site” option will help users to find content pages they are looking for easily and quickly. These are all optional items and if present should be validated.

3) Interface Testing:
The main interfaces are:
Web server and application server interface
Application server and Database server interface.

Check if all the interactions between these servers are executed properly. Errors are handled properly. If database or web server returns any error message for any query by application server then application server should catch and display these error messages appropriately to users. Check what happens if user interrupts any transaction in-between? Check what happens if connection to web server is reset in between?

4) Compatibility Testing:
Compatibility of your web site is very important testing aspect. See which compatibility test to be executed:

  • Browser compatibility
  • Operating system compatibility
  • Mobile browsing
  • Printing options

Browser compatibility:
In my web-testing career I have experienced this as most influencing part on web site testing.
Some applications are very dependent on browsers. Different browsers have different configurations and settings that your web page should be compatible with. Your web site coding should be cross browser platform compatible. If you are using java scripts or AJAX calls for UI functionality, performing security checks or validations then give more stress on browser compatibility testing of your web application.
Test web application on different browsers like Internet explorer, Firefox, Netscape navigator, AOL, Safari, Opera browsers with different versions.

OS compatibility:
Some functionality in your web application is may not be compatible with all operating systems. All new technologies used in web development like graphics designs, interface calls like different API’s may not be available in all Operating Systems.
Test your web application on different operating systems like Windows, Unix, MAC, Linux, Solaris with different OS flavors.

Mobile browsing:
This is new technology age. So in future Mobile browsing will rock. Test your web pages on mobile browsers. Compatibility issues may be there on mobile.

Printing options:
If you are giving page-printing options then make sure fonts, page alignment, page graphics getting printed properly. Pages should be fit to paper size or as per the size mentioned in printing option.

5) Performance testing:
Web application should sustain to heavy load. Web performance testing should include:
Web Load Testing
Web Stress Testing

Test application performance on different internet connection speed.
In web load testing test if many users are accessing or requesting the same page. Can system sustain in peak load times? Site should handle many simultaneous user requests, large input data from users, Simultaneous connection to DB, heavy load on specific pages etc.

Stress testing: Generally stress means stretching the system beyond its specification limits. Web stress testing is performed to break the site by giving stress and checked how system reacts to stress and how system recovers from crashes.
Stress is generally given on input fields, login and sign up areas.

In web performance testing web site functionality on different operating systems, different hardware platforms is checked for software, hardware memory leakage errors,

6) Security Testing:

Following are some test cases for web security testing:

  • Test by pasting internal url directly into browser address bar without login. Internal pages should not open.
  • If you are logged in using username and password and browsing internal pages then try changing url options directly. I.e. If you are checking some publisher site statistics with publisher site ID= 123. Try directly changing the url site ID parameter to different site ID which is not related to logged in user. Access should denied for this user to view others stats.
  • Try some invalid inputs in input fields like login username, password, input text boxes. Check the system reaction on all invalid inputs.
  • Web directories or files should not be accessible directly unless given download option.
  • Test the CAPTCHA for automates scripts logins.
  • Test if SSL is used for security measures. If used proper message should get displayed when user switch from non-secure http:// pages to secure https:// pages and vice versa.
  • All transactions, error messages, security breach attempts should get logged in log files somewhere on web server.

Implement a method to perform basic string compression using the counts of repeated characters.

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Text;

   5:  

   6: namespace _1_05_CompressionString

   7: {

   8:     class Program

   9:     {

  10:         private static int countCompression(string str)

  11:         {

  12:             int size = 0;

  13:  

  14:             char last = str[0];

  15:             int count = 1;

  16:  

  17:             for (int i = 0; i < str.Length; i++)

  18:             {

  19:                 if (str[i] == last)

  20:                 {

  21:                     count++;

  22:                 }

  23:                 else

  24:                 {

  25:                     last = str[i];

  26:                     size += 1 + count.ToString().Length;

  27:                     count = 1;

  28:                 }

  29:             }

  30:             size += 1 + count.ToString().Length;

  31:             return size;

  32:         }

  33:  

  34:  

  35:         private static string Compression1(string str)

  36:         {

  37:             int size = countCompression(str);

  38:             if (size >= str.Length)

  39:             {

  40:                 return str;

  41:             }

  42:  

  43:             StringBuilder stb = new StringBuilder();

  44:             char last = str[0];

  45:             int count = 1;

  46:  

  47:             for (int i = 1; i < str.Length; i++)

  48:             {

  49:                 if (last == str[i])

  50:                 {

  51:                     count++;

  52:                 }

  53:                 else

  54:                 {

  55:                     stb.Append(last);

  56:                     stb.Append(count);

  57:                     last = str[i];

  58:                     count = 1;

  59:                 }

  60:             }

  61:             stb.Append(last);

  62:             stb.Append(count);

  63:  

  64:             return stb.ToString();

  65:         }

  66:  

  67:         private static string Compression2(string str)

  68:         {

  69:             int size = countCompression(str);

  70:             if (size >= str.Length)

  71:             {

  72:                 return str;

  73:             }

  74:  

  75:             string result = string.Empty;

  76:             char last = str[0];

  77:             int count = 1;

  78:  

  79:             for (int i = 1; i < str.Length; i++)

  80:             {

  81:                 if (last == str[i])

  82:                 {

  83:                     count++;

  84:                 }

  85:                 else

  86:                 {

  87:                     result += last.ToString();

  88:                     result += count.ToString();

  89:                     last = str[i];

  90:                     count = 1;

  91:                 }

  92:             }

  93:             result += last.ToString();

  94:             result += count.ToString();

  95:  

  96:             return result;

  97:         }

  98:  

  99:         static void Main(string[] args)

 100:         {

 101:             string str = "abbcccccccccccccccccccccccccccde";

 102:  

 103:             Console.WriteLine("{0} : {1}", str, countCompression(str)); 

 104:  

 105:             Console.WriteLine("{0} : {1}", str, Compression1(str)); 

 106:             Console.WriteLine("{0} : {1}", str, Compression2(str));

 107:  

 108:             Console.ReadKey();

 109:         }

 110:     }

 111: }

Implement an algorithm to determine if a string has all unique characters.

 

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Text;

   5:  

   6: namespace IsUniqueCharacters

   7: {

   8:     class Program

   9:     {

  10:         private static bool isUniqueChars(string str)

  11:         {          

  12:  

  13:             bool[] arrBool = new bool[256];

  14:  

  15:             for (int i = 0; i < str.Length; i++)

  16:             {

  17:                 int val = str[i];

  18:                 if (arrBool[val])

  19:                     return false;

  20:  

  21:                 arrBool[val] = true;

  22:             }

  23:  

  24:             return true;

  25:         }

  26:  

  27:         private static void FindUniqueChars(string str)

  28:         {

  29:             if (!isUniqueChars(str))

  30:             {

  31:                 Console.WriteLine("No unique string");

  32:             }

  33:  

  34:             int[] arrIndex = new int[256];

  35:             for (int i = 0; i < str.Length; i++)

  36:             {

  37:                 arrIndex[str[i]]++;

  38:             }

  39:  

  40:             Console.Write("Duplicate chars in ({0}) = ", str);

  41:             for (int j = 0; j < 256; j++)

  42:             {

  43:                 if (arrIndex[j] > 1)

  44:                     Console.Write("{0} ", (char)j);

  45:             }

  46:             Console.WriteLine();

  47:         }

  48:  

  49:  

  50:         static void Main(string[] args)

  51:         {

  52:             string[] arrStrings = new string[] { "abcdedisp", "akcidiugs", "sacddes", "abcsnil", "abckiipdnsu", "iiiiiiii", "aaaiiimmm" };

  53:  

  54:             foreach (string str in arrStrings)

  55:             {

  56:                 if (isUniqueChars(str))

  57:                     Console.WriteLine("{0} is Uniq", str);

  58:                 else

  59:                     Console.WriteLine("{0} is NOT Uniq", str);

  60:  

  61:                 FindUniqueChars(str);

  62:  

  63:             }

  64:  

  65:             Console.ReadKey();

  66:         }

  67:     }

  68: }