Tuesday, 10 November 2015

Software Testing - Part 2

Testing Methodologies


1. Testing Techniques

Manual Testing
The first testing we experience when we learn to program is manual testing: try the program and see if it works!
In manual testing, the tester plays the role of a user and check to see if there is any unexpected or undesirable behavior.
Often, manual testers will use a test plan with specified test cases to ensure a thorough exploration of the project.
The tester may or may not be part of the programming team that created the code.


Automated Testing

Automated tests use testing software to control and track one or more automatically executed tests.
Automated tests can be created and configured to run each time a new version of the project is created.
Microsoft Test Manager will provide detailed reporting on the test results for each automated test.

Manual vs. Automated Testing

Manual and automated test cases are complementary, both types of tests are important for ensuring high quality software.
Automation is quick and can test many subtle variations in data, it can also easily repeat tests as software evolves. And because it is executed by a computer, the fatigue and mistakes that sometimes accompany repetitive tasks is negated.
Although manual testing typically takes longer to execute (since it’s conducted by a person), it often requires far less set-up time. It is a good choice for tests that only need to be run occasionally, or cases when cost/time of automation setup would outweigh the benefits.


Black Box Testing

Black box testing is testing conducted without knowledge of the internal workings of the system that is being tested. This type of testing simulates end-user experience.
In general, the tester does not know how the code works, she or he is providing input and examining the output. This person does not necessarily need to know how to program.
Example scenarios for black box testing include:
  • Testing that the user interface meets all requirements and is functional
  • Testing for a variety of input types (including input outside the expected range, such as entering a negative number for a weight)
  • Load or stress testing a system
  • Testing the security of a project or system.

White Box Testing

White box testing is conducted by examining code for potential failure scenarios.
White box test cases are created by someone who analyzes the code of the application block and prepares test cases to ensure that the class is behaving in accordance with the specifications.
White box scenarios include:
  • Testing internal subroutines that are used "behind the scenes"
  • Testing loops and conditional statements for accuracy
  • Performance testing of a code path or algorithm



2. Testing Levels

Unit Testing
Unit tests are automated tests that verify functionality at the component, class, method, or property level.
The primary goal of unit testing is to take the smallest piece of testable software in the application, isolate it from the remainder of the code, and determine whether it behaves exactly as you expect.
Each unit is tested separately before integrating them into components to test the interfaces between units.
Unit tests should be written before (or very soon after) a method is written. Often, developers building the class or method designs the unit test themselves.


Component and Integration Testing

From a testing perspective, individual units are integrated together to form larger components. In its simplest form, two units that have already been tested are combined into an integrated component and the interface between them is tested. This testing is called integration testing (or “component testing”).
Integration testing identifies problems that occur when units are combined. New errors that arise are likely related to the interface between units rather than within the units themselves—this simplifies the task for finding and correcting the defects.


3. Testing Types

Regression Testing

Whenever any changes are made to a project, it is possible that existing code may no longer work properly, or that previously undiscovered bugs will present themselves. This kind of bug is called a regression.
To catch these defects, the entire project must be regression tested: a complete retesting of a modified program, rather than a test of only the modified units, to ensure that no errors have been introduced with the modifications.


Stress Testing

Testing on a small scale, such as a single user running a web application or a database with only a handful of records, may not reveal problems that may occur when the application is used in “real world” conditions.
Stress testing pushes a system’s functional limits. It is performed by subjecting the system to extreme conditions, such as peak volumes of data or a large number of simultaneous users.
These tests are also referred to as load tests, since they test a system under heavy loads.
Test automation allows rigorous stress testing without a minimal amount of manual labor.

Performance Testing

Performance testing determines responsiveness, throughput, reliability, and/or scalability of a system under a given workload.
In web applications, performance testing is often closely related to stress testing, measuring lag and responsiveness under a heavy load.
In other applications (desktop and mobile apps, for example), performance testing measures speed and resource utilization, such as disk space and memory.


Security Testing

Security testing validates an application's security services and identifies potential security flaws.
Many projects use a black box approach to security testing, allowing security experts with no knowledge of the software to probe the application for holes and weaknesses.

Usability Testing

Usability testing evaluates a project by studying how real users actually use the software.
Examples include:
  • Measuring how long it takes a user to complete a task
  • Tracking how many “clicks” or user actions it takes to complete a task or access a feature.
Localization Testing
Localization translates the product UI and occasionally changes some initial settings to make it suitable for another region.


Accessibility Testing

Accessibility testing validates an application’s support for users with disabilities.
Accessibility testing may include:
  • Compliance: Does it comply with legal requirements regarding accessibility?
  • Effectiveness: Can users with disabilities use the application?
  • Usefulness: Does the application expose adequate functionality for users with disabilities?
  • Satisfaction: How is the application perceived by users with disabilities?
  • Accessibility testing may include usability tests with disables users and assistive technology devices.


Wednesday, 23 September 2015

Software Testing - Part 1

Software Testing Fundamentals

Testing is the process of examining an application to ensure it fulfills the requirements for which it was designed and meets quality expectations.
Testing measures the quality of an application or project.
Developers should take the view that your project does have bugs or defects that have not yet been discovered. Testing helps find and correct those defects.
A bug is an error in coding or logic that causes a program to malfunction or to produce incorrect results.


Importance of Software Testing
  • Reduces the cost of developing the program
  • Ensures that your application behaves exactly as intended
  • Reduces the total cost of ownership for end users
  • Develops customer loyalty and word-of-mouth market share



Testing benefits for End Users

Early testing results in software with better usability and reliability, as well as a lower cost of ownership.
  • Bugs caught during testing do not require users to spend time identifying bugs
  • Bugs caught before a project is delivered do not cost the user any downtime while fixes are created and updates are installed
  • Software that behaves as expected requires less training and user support
  • Software that is well-tested results in increased user satisfaction



Reference:


Thursday, 10 September 2015

Another Knockout example and a lesson learnt

Setup the project to use Knockout in a Visual Studio project, see: Setting up a Visual Studio Project for use with Knockout


1. Add the following Knockout code in the <script> tag in the header
<script>
/// <reference path="/Scripts/knockout-3.3.0.js"/>
   function AppViewModel() {
       this.firstName = ko.observable();
       this.lastName = ko.observable();
       this.msg = ko.observable();
           
       this.writeMsg = function () {
           var p1 = this.firstName() + " " + this.lastName();
           this.msg("Hello " + p1);
       };
   }
   // Activates knockout.js
   ko.applyBindings(new AppViewModel());
</script>


2. Add the following html code in the body of the document
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<button data-bind="click: writeMsg">Show</button>
<p data-bind="text: msg"></p>


3. Save your document and right-click the background of the document and select View in Browser
4. You are getting an error:”Error: Unable to get property ‘nodeType’ of undefined or null reference” - a lesson learnt
5. The reason is that the Knockout code is trying to execute before the objects in the document has been initialised
6. To fix this, move the script block with the Knockout code to the bottom of the document, just before the closing </body> tag
7. Run the page again and it should work as expected
8. See the complete code below:


<!DOCTYPE html>
<html>
<head>
   <title>Knockout Example</title>
<meta charset="utf-8" />
   <script src="Scripts/knockout-3.3.0.js"></script>
</head>
<body>
   <p>First name: <input data-bind="value: firstName" /></p>
   <p>Last name: <input data-bind="value: lastName" /></p>
   <button data-bind="click: writeMsg">Show</button>
   <p data-bind="text: msg"></p>


   <script>
   /// <reference path="/Scripts/knockout-3.3.0.js"/>
       function AppViewModel() {
           this.firstName = ko.observable();
           this.lastName = ko.observable();
           this.msg = ko.observable();
           this.writeMsg = function () {
               var p1 = this.firstName() + " " + this.lastName();
               this.msg("Hello " + p1);
           };
       }
       // Activates knockout.js
       ko.applyBindings(new AppViewModel());
   </script>
</body>

</html>

Basic usage of Knockoutjs in a website

Setup the project to use Knockout in a Visual Studio project, see: Setting up a Visual Studio Project for use with Knockout


1. In this example, the styles and the javascript were declared inline in the document
2. Add the styles in the <style> tag in the header,
3. Add the View (the HTML) in the <body> of the document
4. Add the Model in a <script> tag in the body of the page
5. Add the ViewModel, also in the above <script> tag
6. Bind the ViewModel, also in the above <script> tag
7. See the complete example below
8. Set your Index page as the default page for the project
9. Run the project and see what Knockout can do for you


<!DOCTYPE html>
<html>
<head>
   <title>Using KnockoutJS in a Web Page</title>
   <meta charset="utf-8" />
   <script src="Scripts/knockout-3.3.0.js"></script>
   <style>
       body {
           margin: 10px;
       }
       span {
           margin: 0 10px 0 0;
       }
       .descArea {
           padding: 10px;
           background-color: lightgray;
           border: black 1px solid;
       }
   </style>
</head>
<body>

   <span data-bind="text: shortDesc"></span>
   <div data-bind="text: description" class="descArea"></div>
   <span data-bind="text: formatCurrency(salesPrice)"></span>

   <script>
 /// <reference path="/Scripts/knockout-3.3.0.js"/>
       //The Model
       var data = {
           "Id": 123,
           "SalesPrice": 12500,
           "ListPrice": 16250,
           "ShortDesc": "Yamaha RD 350",
           "Description": "Yamaha RD 350 roadbike with helmet, jacket and gloves"
       };

       //The ViewModel
       var viewmodel = {
           id: ko.observable(data.id),
           salesPrice: ko.observable(data.SalesPrice),
           listPrice: ko.observable(data.ListPrice),
           shortDesc: ko.observable(data.ShortDesc),
           description: ko.observable(data.Description),
           formatCurrency: function (value) {
               return "R " + value().toFixed(2);
           }
       };

       //Bind the Viewmodel
       ko.applyBindings(viewmodel);
   </script>

</body>
</html>

Monday, 7 September 2015

Setting up a Visual Studio Project for use with Knockout

1. Open up Microsoft Visual Studio (this example was prepared on MS Visual Studio 2015)
2. Create a New Project
3. Choose ASP.Net Web Application from Installed templates
4. Choose Empty from Select a Template window
5. The Solution Explorer will look as follows:


6. Add KnockoutJS with NuGet package manager


7. Your solution will now look as follow:


8. Create a new Index.html page
9. Add the references to the knockout libraries in the <head> tag
10. See the code below:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="Scripts/knockout-3.3.0.js"></script>
</head>
<body>


</body>
</html>

11. With above document, you are ready to do some exercises with KnockoutJS!