Tuesday, January 8, 2013

SOFTWARE TESTING


SDLC  & STLC:

Software Development Life Cycle involves the complete Verification and Validation of a Process or a Project. 
Whereas Software Testing Life Cycle involves only Validation. 


Software Development Life Cycle involves business requirement specifications,Analysis,Design,Software requirement specifications,Development Process(Coding and Application development),Testing Process(Preparation of Test Plan,Preparation of Test cases,Testing,Bug reporting,Test Logs & Test Reports),Implementation and Maintainence . 
Whereas Software Testing Life Cycle involves Preparation of Test Plan,Preparation of Test cases,Testing,Bug reporting,Test Logs & Test Reports.


Software testing is an important part of the software development process. In normal software development there are four important steps, also referred to, in short, as the PDCA (Plan, Do, Check, Act) cycle.



Let's review the four steps in detail.

1.    Plan: Define the goal and the plan for achieving that goal.
2.    Do/Execute: Depending on the plan strategy decided during the plan stage we do execution accordingly in this phase.
3.    Check: Check/Test to ensure that we are moving according to plan and are getting the desired results.
4.    Act: During the check cycle, if any issues are there, then we take appropriate action accordingly and revise our plan again.


So developers and other stakeholders of the project do the "planning and building," while testers do the check part of the cycle. Therefore, software testing is done in check part of the PDCA cyle.

CMMI model: Capability Maturity Model Integration

There are five maturity levels in a staged representation as shown in the following figure.


Maturity Level 1 (Initial): In this level everything is adhoc. Development is completely chaotic with budget and schedules often exceeded. In this scenario we can never predict quality. 



Maturity Level 2 (Managed): In the managed level basic project management is in place. But the basic project management and practices are followed only in the project level.



Maturity Level 3 (Defined): To reach this level the organization should have already achieved level 2. In the previous level the good practices and process were only done at the project level. But in this level all these good practices and processes are brought to the organization level. There are set and standard practices defined at the organization level which every project should follow. Maturity Level 3 moves ahead with defining a strong, meaningful, organizational approach to developing products. An important distinction between Maturity Levels 2 and 3 is that at Level 3, processes are described in more detail and more rigorously than at Level 2 and are at an organization level.



Maturity Level 4 (Quantitatively measured): To start with, this level of organization should have already achieved Level 2 and Level 3. In this level, more statistics come into the picture. Organization controls the project by statistical and other quantitative techniques. Product quality, process performance, and service quality are understood in statistical terms and are managed throughout the life of the processes. Maturity Level 4 concentrates on using metrics to make decisions and to truly measure whether progress is happening and the product is becoming better. The main difference between Levels 3 and 4 are that at Level 3, processes are qualitatively predictable. At Level 4, processes are quantitatively predictable. Level 4 addresses causes of process variation and takes corrective action.



Maturity Level 5 (Optimized): The organization has achieved goals of maturity levels 2, 3, and 4. In this level, processes are continually improved based on an understanding of common causes of variation within the processes. This is like the final level; everyone on the team is a productive member, defects are minimized, and products are delivered on time and within the budget boundaThe following figure shows, in detail, all the maturity levels in a pictorial fashion.


Black box testing is a testing strategy based solely on requirements and specifications. Black box testing requires no knowledge of internal paths, structures, or implementation of the software being tested.


White box testing is a testing strategy based on internal paths, code structures, and implementation of the software being tested. White box testing generally requires detailed programming skills.



There is one more type of testing called gray box testing. In this we look into the "box" being tested just long enough to understand how it has been implemented. Then we close up the box and use our knowledge to choose more effective black box tests.

 Black box testers view the basic accounting application. While during white box testing the tester knows the internal structure of the application. In most scenarios white box testing is done by developers as they know the internals of the application. In black box testing we check the overall functionality of the application while in white box testing we do code reviews, view the architecture, remove bad code practices, and do component level testing.


Usability testing is a testing methodology where the end customer is asked to use the software to see if the product is easy to use, to see the customer's perception and task time. The best way to finalize the customer point of view for usability is by using prototype or mock-up software during the initial stages. By giving the customer the prototype before the development start-up we confirm that we are not missing anything from the user point of view.




Configuration management is the detailed recording and updating of information for hardware and software components. When we say components we not only mean source code. It can be tracking of changes for software documents such as requirement, design, test cases, etc.


When changes are done in adhoc and in an uncontrolled manner chaotic situations can arise and more defects injected. So whenever changes are done it should be done in a controlled fashion and with proper versioning. At any moment of time we should be able to revert back to the old version. The main intention of configuration management is to track our changes if we have issues with the current system. Configuration management is done using baselines.


Unit testing - Testing performed on a single, stand-alone module or unit of code.


Integration Tests - Testing performed on groups of modules to ensure that data and control are passed properly between modules.



System testing - Testing a predetermined combination of tests that, when executed successfully meets requirements.



Acceptance testing - Testing to ensure that the system meets the needs of the organization and the end user or customer (i.e., validates that the right system was built).





Alpha and beta testing has different meanings to different people. Alpha testing is the acceptance testing done at the development site. Some organizations have a different visualization of alpha testing. They consider alpha testing as testing which is conducted on early, unstable versions of software. On the contrary beta testing is acceptance testing conducted at the customer end.



In short, the difference between beta testing and alpha testing is the location where the tests are done.

In some projects there are scenarios where we need to do boundary value testing. For instance, let's say for a bank application you can withdraw a maximum of 25000 and a minimum of 100. So in boundary value testing we only test the exact boundaries rather than hitting in the middle. That means we only test above the max and below the max. This covers all scenarios. The following figure shows the boundary value testing for the bank application which we just described. TC1 and TC2 are sufficient to test all conditions for the bank. TC3 and TC4 are just duplicate/redundant test cases which really do not add any value to the testing. So by applying proper boundary value fundamentals we can avoid duplicate test cases, which do not add value to the testing.
In equivalence partitioning we identify inputs which are treated by the system in the same way and produce the same results. You can see from the following figure applications TC1 and TC2 give the same results (i.e., TC3 and TC4 both give the same result, Result2). In short, we have two redundant test cases. By applying equivalence partitioning we minimize the redundant test cases.


So apply the test below to see if it forms an equivalence class or not:

  • All the test cases should test the same thing.
  • They should produce the same results.
  • If one test case catches a bug, then the other should also catch it.
  • If one of them does not catch the defect, then the other should not catch it.
Random testing is sometimes called monkey testing. In Random testing, data is generated randomly often using a tool. For instance, the following figure shows how randomly-generated data is sent to the system. This data is generated either using a tool or some automated mechanism.

A negative test is when you put in an invalid input and receive errors.


A positive test is when you put in a valid input and expect some action to be completed in accordance with the specification.



Exploratory testing is also called adhoc testing, but in reality it's not completely adhoc. Ad hoc testing is an unplanned, unstructured, may be even an impulsive journey through the system with the intent of finding bugs. Exploratory testing is simultaneous learning, test design, and test execution. In other words, exploratory testing is any testing done to the extent that the tester proactively controls the design of the tests as those tests are performed and uses information gained while testing to design better tests. Exploratory testers are not merely keying in random data, but rather testing areas that their experience (or imagination) tells them are important and then going where those tests take them.

Regression testing is used for regression defects. Regression defects are defects occur when the functionality which was once working normally has stopped working. This is probably because of changes made in the program or the environment. To uncover such kind of defect regression testing is conducted. 

TestCase For ATM:
C 1:- successful card insertion.


TC 2:- unsuccessful operation due to wrong angle card insertion.



TC 3:- unsuccessful operation due to invalid account card.



TC 4:- successful entry of pin number.



TC 5:- unsuccessful operation due to wrong pin number entered 3 times.



TC 6:- successful selection of language.



TC 7:- successful selection of account type.



TC 8:- unsuccessful operation due to wrong account type selected w/r to that inserted card.



TC 9:- successful selection of withdrawal option.



TC 10 :- successful selection of amount.



TC 11:- unsuccessful operation due to wrong denominations.



TC 12:- successful withdrawal operation.



Tc 13 :- unsuccessful withdrawal operation due to amount greater than possible balance.



TC 14 :- unsuccessful due to lack of amount in ATMhttp://images.intellitxt.com/ast/adTypes/icon1.png.



TC 15 :-un due to amount greater than the day limit.



TC 16 :- un due to server down.



TC 17 :- un due to click cancel after insert card.



TC 18:- un due to click cancel after indert card and pin no.



TC 19:- un due to click cancel after language selection,account type selection,withdrawal selection, enter amount




Tuesday, November 20, 2012


SQL-What is a View

A View is a "Virtual Table". It is not like a simple table, but is a virtual table which contains columns and data from different tables (may be one or more tables). A View does not contain any data, it is a set of queries that are applied to one or more tables that is stored within the database as an object. After creating a view from some table(s), it used as a reference of those tables and when executed, it shows only those data which are already mentioned in the query during the creation of the View.
View1.JPG

Views are used as security mechanisms in databases. Because it restricts the user from viewing certain column and rows. Views display only those data which are mentioned in the query, so it shows only data which is returned by the query that is defined at the time of creation of the View. The rest of the data is totally abstract from the end user.
Along with security, another advantage of Views is data abstraction because the end user is not aware of all the data in a table.

Uses

We begin with creating 3 tables PRODUCTSCustomer BOOKING. These are fictitious tables for our demo. ThePRODUCTS stores data for a retail shop with a flag column IsSalable based on whose value we treat the products as Salable.
CREATE TABLE PRODUCTS
(ProductID INT PRIMARY KEY CLUSTERED,
ProductDesc VARCHAR(50) NOT NULL,
ManufacturingDate DATETIME,
ExpiryDate DATETIME,
IsSalable BIT,--1 Salable/Active FOR 0 For NonSalable/Passive Product
Price MONEY NOT NULL
)
Next, we have a Customer table which stores UserID and Password details for customers.
CREATE TABLE Customer
(CustID INT IDENTITY(1002,2)PRIMARY KEY CLUSTERED,
 FName VARCHAR(50) NOT NULL,
 LNme VARCHAR(50) NOT NULL,
 UserID VARCHAR(100) NOT NULL,
 Pswd NVARCHAR(100) NOT NULL DEFAULT 'password123'
)
Lastly, I have created a BOOKING table which houses all the bookings from different customers.
CREATE TABLE BOOKING
( BookingID INT IDENTITY(10,2) PRIMARY KEY CLUSTERED,
  ProductID INT REFERENCES dbo.Products(ProductID),
  CustID INT REFERENCES dbo.Customer(CustID),
  DateOfBooking DATETIME NOT NULL,
  QTY INT
)
Next, insert a few records into these tables:
INSERT INTO PRODUCTS VALUES
(1,'Biscuits','2011-09-01 00:00:00.000','2012-09-01 00:00:00.000',1,20),
(2,'Butter','2010-09-01 00:00:00.000','2011-09-01 00:00:00.000',1,30),
(3,'Milk','2011-10-01 00:00:00.000','2011-11-01 00:00:00.000',1,46)

INSERT INTO Customer (FName,LNme,UserID,Pswd)
 VALUES
('Sara','Verma','S.Verma@abc.com','S123'),
('Rick','Singh','G.Singh@xyz.com','G311'),
('Micky','Khera','M.Khera@mno.com','M222')

INSERT INTO BOOKING (ProductID,CustID,DateOfBooking,QTY)
VALUES
(1,1002,'2011-11-01 00:00:00.000',3),
(2,1004,GETDATE(),4),
(3,1006,'2011-10-01 00:00:00.000',2)
Our tables contents look like this. I know the tables are not completely normalized, for now please ignore them, these are simple demo tables.
SELECT * FROM Customer
CustID      FName     LNme    UserID           Pswd
--------- -------- ---------- ---------------  ---------
1002        Sara   Verma      S.Verma@abc.com  S123
1004        Rick   Singh      G.Singh@xyz.com  G311
1006        Micky  Khera       M.Khera@mno.com M222

(3 row(s) affected)

Select * from PRODUCTS

ProductID  ProductDesc  ManufacturingDate       ExpiryDate              IsSalable Price
---------- ------------ ----------------------- ----------------------- --------- -------
1          Biscuits     2011-09-01 00:00:00.000 2012-09-01 00:00:00.000 1         20.00
2          Butter       2010-09-01 00:00:00.000 2011-09-01 00:00:00.000 1         30.00
3          Milk         2011-10-01 00:00:00.000 2011-11-01 00:00:00.000 1         46.00

(3 row(s) affected)

Select * from BOOKING
BookingID   ProductID   CustID      DateOfBooking           QTY
----------- ----------- ----------- ----------------------- -----------
10          1           1002        2011-11-01 00:00:00.000 3
12          2           1004        2011-10-09 17:31:31.790 4
14          3           1006        2011-10-01 00:00:00.000 2

(3 row(s) affected)
customer purchases/books a product and the same gets recorded into the BOOKING table now to generate the bill on his name we can uses a VIEW which would help us do away with a physical table. Instead it would enable us to generate the bill based on the information from these 3 tables itself. Let’s see how it’s possible.
CREATE VIEW Bill_V
AS
SELECT C.FName
      ,C.LNme
      ,P.ProductDesc
      ,B.DateOfBooking
      ,P.Price
      ,B.QTY
      ,(B.QTY*P.Price) AS TotalAmountPayable
FROM BOOKING B
INNER JOIN PRODUCTS P
ON B.ProductID=P.ProductID
INNER JOIN Customer C
ON B.CustID=C.CustID;
Next if I,
Select * from Bill_V
FName     LNme   ProductDesc DateOfBooking         Price   QTY     TotalAmountPayable
-------------------------------------------------- ------------------------------------
Sara      Verma  Biscuits   2011-11-01 00:00:00.000 20.00  3       60.00
Rick      Singh  Butter     2011-10-09 17:31:31.790 30.00  4       120.00
Micky     Khera  Milk       2011-10-01 00:00:00.000 46.00  2       92.00

(3 row(s) affected)
We have been able to generate the bill based on the 3 tables hence we have not only optimized the bill generation also we have saved ourselves from hosting a physical table in the database with this information.
  • This is the most credible use of a VIEW; it can not only reduce apparent complexity but also prevent redundant hosting of data in the DB.Next say there is some API which enables the Customer care executives to view the customerinformation details. Now exposing the Password might be risky, it’s strictly confidential info.
    We create a View which can be exposed to the API:
    CREATE VIEW dbo.CustomerInfo_V
    AS
    Select CustID
          ,FNAME AS [FIRST NAME]
          ,LNME AS [LAST NAME]
          ,UserID
    FROM dbo.Customer
    We have a created a View which can be used by the API to fetch customer details –(Minus) the Password Column.
  • Views can be used to prevent sensitive information from being selected, while still allowing other important data.Views do not have a physical existence, but still they do return a set of record set as a table does, the differences is it is simply an additional layer which calls the underlying code which finally returns the record set.



Sunday, November 18, 2012

How to start in Stock Markets?



Would you like to become a business owner without ever having to show up at work? I am sure all of you would. I am not talking about you getting a windfall gain through dowry; I am talking about you holding shares of a listed company on stock markets.
You must be wondering what this stock marketis? No, it is not a place where you sell goods, it is a place where securities (like shares and bonds) are bought and sold. ‘Share’ means a share in share capital of the company. In simple terms, if you buy some shares of a company you get part ownership of that company. Sounds good? Yes, it is very simple – but there is always risk involved in it. Why do I say it is risky? The value of a share can go down for several known and unknown reasons.
So how does one go about buying shares? How can I become a successful investor like Warren Buffet? FYI – Warren Buffet is widely regarded as one of the most successful investor in the world. Before you buy shares, you should know where and how you can buy them.
Step 1:  First open a Trading and Demat account with a registered broker. I don’t understand what this Trading Account or Demat Account mean, can you elaborate? ‘Trading Account’ – Just like you need a bank account to debit and creditcash, you need a trading account to buy and sell shares ‘Demat Account’ refers to dematerialized account which holds all your share certificates in electronic form rather than paper. How would you do that?
Simple, go to Google and search for registered brokerage houses in India you will find so many companies like HDFC, ICICI, SBI etc. Go to any brokerage house website you want to open your account with and call the toll free numberavailable on the website – within few minutes a representative from that company will fly into your house to give all necessary details of opening a new account.
Step 2: After collecting information of two or three brokerage firms you might decide to open an account with one who charges less brokerage charge and gives you good customer caresupport. What is a brokerage charge? When you buy or sell shares you will have to pay .5% or even less charge for that transaction. What other expenses do I incur when I buy/sell shares? You pay service tax and some other taxes for that transaction. How will I know about these charges? You will receive a report onto your email the same day or the next day of yourtrade.
Step 3: After having decided to open a Tradingand Demat account. You should mentally prepare yourself to sign several pages of application formAh! Once you are done you need to wait for few more days to get your account activated. Yuppie! You’re done with registration and activation. What next? You need to put some money intoyour account. How much?
Start Small – Don’t put all your money initially. First, learn about yourself and the market. What kind of player are you? Are you an Investor or a Trader or a Gambler? Gamblers are those who treat market as casino and play with it - never become a gambler unless you are a rich guy and you just want spend..spend..and only spend.Trader is an opportunist, who takes advantage of mispricing and makes profit from excessive greed and fear. An Investor is one who is optimistic, who has a long term view, who is ‘buy and hold’ types – who does lot of fundamental analysis of the company and buys shares which he thinks would do well in future.
Don’t get excited and jump without thinking – start learning about stock markets. What is NIFTY? What is SENSEX? How to analyze a company? How to select a good company in the current scenario? Read articles, books on fundamental analysis like ‘Warren Buffet way’ by Robert Hagstorm.
Now I know the basics of stock markets, what next? Observe the market. How it is behaving? Why is it going up/down? What do so called experts on the news channel say? You may wonder “how long should I observe the market?” The answer is “till you become completely familiar and confident about your decision to buy some company stocks/shares”. Try to get details about Price-Equity Ratio (P/E Ratio), Market Cap, Volumes etc of the company you are interested in -understand the business model. Shortlist one good stock which you think would do well in future and can give you above average returns – Invest in small quantities.
Don’t relax - keep tracking the company you have invested in; have a target price in mind; sell shares when you reach the target. Always good to be prepared for uncertainty, isn’t it? Have max fall of the share from your buying price you can afford to lose in mind; if the price of the share falls below that value; sell them by booking loss.
Practice and have a strategy that gives you good returns and learn from your mistakes.
Remember, stock markets are not a place to become rich overnight. Only few people are successful in this profession.