Wednesday, 25 June 2014

Structured Query language


What is SQL?
  • A data manipulation language
  • It is useful in communicating with the data base
  • Mostly it will be in the table format
  • Not a case sensitive
  • ; is a not mandatory
Its is classified into three types, DDL, DML AND DQL.
1. DDL(Data Definition Language)
Create, Drop and Alter
CREATE
Syntax: create table table_name(
integer_variable int  // employee_id int;
String Varchar(n) // Employee_name varchar(30);
);
How to see the table after creating?
select * form table_name
DROP
Syntax: Drop table table_name
ALTER
alter table table_name add Employee_city varchar(30);
alter table table_name drop column Emp_city
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2. DML(Data Manipulation Language)
Insert, Delete and Update
INSERT
Syntax: insert into table_name values(5,’Aneesh’,22000); // String should be always should be within the single quotes
(or)
insert into table_name (ename,esal) values (Panda,9000)
(or)
insert into table_name values(null,’hell boy’,25000)
UPDATE
Syntax: update table_name set eid=96 where ename=Aneesh
DELETE
Syntax: delete from table_name where eid=25
delete from table_name // it will delete all the contents in the table
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3. DQL(Data Query Language)
Relational Operators (<,>,<=,>=,=,<>) \\ <> not equal to
example: select * form table_name where Esal>25000
Logical Operators
A    B              AND     OR 
0    0               0           0     
0    1               0           1
1    0               0           1
1    1               1           1
A   NOT
0     1
1     0
Syntax:
select * form table_name where Eid=5 AND Ename=Panda
Note: If both are correct value it will display else nothing.
select * form table_name where Eid=5 OR Ename=Panda
Note: both the different rows are executed.

BETWEEN AND
Syntax: select * from table_name where Esal between 20000 and 60000
IN
Syntax: select * from table_name where Ejob in (‘System Admin’,’Test Lead’)
select * from table_name where Esal in (10000,20000,30000)
NOT
Syntax: select * form table_name where Esal not in (5000)
select * from table_name where Ename not like (‘%a’) // it will not show the name ends with a
Like – %a – string ends with a and a% – string starts with a
IS NULL
select * form table_name where Eid is null // if we left blank or when we specify null those can be identified
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CONSTRAINTS
UNIQUE KEY – Where we don’t need the repeat in the values example Employee id should not repeat where we can use this unique key
int EID unique
NOT NULL – Where do not need the value to be null. We can use in the name field
Employee_name varchar(30) not null
DEFAULT – When we assign default value, when we left blank or null it will auto assign
Ecity varchar(30) default ‘chennai’ // note if we specifly assign NULL it will not take the default value.
CHECK - Ensures that the value in a column meets a specific condition
eid int unique, check (eid>100)
PRIMARY KEY – Combination of unique and not null key but can be used only once for a column in a table
Eid int primary key
FOREIGN KEY - Ensure the referential integrity of the data in one table to match values in another table
eid int foreign key refrerences emp1(eid)
Note: Eid values of both the tables should be same
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
JOINS

SQL join is a technique to join two or more tables on a specific condition(where clause) and retrieve desired result.
The different types are:
  • INNER JOIN: Returns all rows when there is at least one match in BOTH tables
  • LEFT JOIN: Return all rows from the left table, and the matched rows from the right table
  • RIGHT JOIN: Return all rows from the right table, and the matched rows from the left table
  • FULL JOIN: Return all rows when there is a match in ONE of the tables
  • SELF JOIN: A table can be joined to same table. Mostly used when a table has parent-child relationship in the same table
INNER JOIN
Select column_name(s) from table_name1 INNER JOIN table_name2
on table_name1.column_name = table_name2.column_name
LEFT JOIN
Select column_name(s) from table_name1 LEFT JOIN table_name2
on table_name1.column_name = table_name2.column_name
RIGHT JOIN
Select column_name(s) from table_name1 RIGHT JOIN table_name2
on table_name1.column_name = table_name2.column_name
FULL JOIN
Select column_name(s) from table_name1 FULL JOIN table_name2
on table_name1.column_name = table_name2.column_name
ORDER BY
If needed we can also sort the columns,
Select column_name(s) from table_name1 FULL JOIN table_name2
on table_name1.column_name = table_name2.column_name
ORDER BY Column_name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IN BUILT FUNCTIONS
1. AVG() – to find the average of a column
select avg(Column_name) from Table_name
2. Count() – to count the number of column count
3. Sum() – to sum of all the values in the column
4. Max() and Min() – to find the maximum and minimum values in the column
5.Group by - is used in collaboration with the SELECT statement to arrange identical data into groups.
6. Having - enables you to specify conditions that filter which group results appear in the final results.
The WHERE clause places conditions on the selected columns, whereas the HAVING clause places conditions on groups created by the GROUP BY clause.
Select Employee_job, sum(Emp_salary) from Table_name GROUP BY Employee_job having sum(Employee_salary)>200000
7. UPPER() – to display in Upper case
8. LOWER() – to display in lower case
9. Get Date() – Returns the current system date and time
10. Len() – Returns the length of the text field
11. Round() – rounds the value
select round (column_name, decimal) from table_name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TRANSACTION CONTROL LANGUAGE (TCL)
COMMIT, ROLL BACK & SAVE
Commit - What ever we type on the sql server it automatically commits that is saves the statements or lines but not permanently
ROLL BACK
We need to begin the transaction as
BEGIN TRANSACTION TRANSACTION_NAME
insert some values or do any operations
when we say
ROLLBACK TRANSACTION TRANSACTION_NAME
what ever the operation after the begin transaction is deleted.
SAVE
Begin the transaction
insert some values or do any operations
now, save the transaction
SAVE TRANSACTION TRANSACTION_NAME
Once Saved the transaction cannot be rolledback.
 
 
 












































Tuesday, 10 June 2014

Getting Started with SELENIUM IDE

·         Selenium is one of the most well known testing frameworks in the world that is in use which is introduced by Jason Huggins in 2004.
·         It is an open source project that allows testers and developers alike to develop functional tests to drive the browser.
·         It can be used to record the workflows and used to prevent the future regressions of code.
·         It supports Java Scripts and has been built with the same

The components of Selenium are :
1.      IDE
2.      RC
3.      Web Driver &
4.      Grid


SELENIUM IDE

The selenium IDE is a Firefox Add-on developed by Shinya Kasatani. It has been developed using Java Scripts so that it can interact with DOM (Document Object Model) using native JavaScript calls.
You can install the Firefox first and also install the selenium IDE from the link,
www.seleniumhq.org  à Downloadà Download latest released version 2.5.0


Install fire pathàhttps://addons.mozilla.org/en-US/firefox/addon/firepath/

Open you Firefox browser where toolsà Selenium IDE



The items in the IDE,
Base URL: All open command will be relative to the base URL (full path). This is the URL that the test will start at.

Speed Slider: This slider is used to fast or slow mode during the play back.

(Triangle with 3 lines): Run all the tests in the id

(Triangle with 1 line): Run only single test

(||): Pause a test that is currently running

(bended down arrow): Step through the test once it has paused

Red button- This is the Record button. By default when we open the selenium IDE it will be enabled.

Command -     It is a select box has a list of all the commands that are needed to create the test. It is an auto complete functionality or use the drop down.

Target - the location of the element

Value - where you place the value that needs to be change.

Table view – Will keep track all the commands, targets and values.

Source View – You will be able to see the HTML that will store the test.

Log – will show what is happening during the test run.

Reference – Documentation on the command highlighted.

For all examples we are going to test the following link: http://theautomatedtester.co.uk/ 

Record your first Test with the Selenium IDE

         1.      First need to start the Mozilla Firefox and need to start the Selenium IDE. It will be automatically in the  record mode.
         2.      Now in browser navigate to http://theautomatedtester.co.uk/chapter1
         3.      Do some action on the web application like click on the links radio buttons etc
         4.      Once the actions are done come back to IDE and stop recording.
         5.      Your test has been recorded
         6.      Now you can play the test and see the result.
         7.      If any failures it will display the number of failures and errors can be viewed in the log

VERIFY AND ASSERT

Verify – is going to verify the element present on the page. If not it will throw the error and carry on executing.

Assert- Is very similar to verify but the difference is, this allows the test to check if the element is on the page. If not the test will stop on the step that failed.

How to use Verify or Assert?

          1.      Open Selenium IDE and start recording
          2.      Right on the text which you would like to verify
          3.      Show all available commands and select verify text
          4.      Do few more action and stop recording
          5.      Now run the test

When it verifies that particular step will be highlighted in dark green color. If it does not match or verify it will throw error and carry on executing remaining commands.

Same procedures for Assert:

Right click on the text you need to verify and select assert text.

Here if it matches or verifies same procedure like verify, but when it does not verifies it will fail and stop executing the remaining steps.

How we have verified the text, in the same procedure we can verify the element present like buttons, checkbox, text area etc in the chapter 1. You can try yourself. The result will be like the following,





 How to Comment?

1.      Click on any step that you want to comment.
2.      Right click and click on Insert New Comment
3.      A new line will appear
4.      Type your comments in the command.
5.      You can see a pink color line ie. Comment

How to use multiple windows?

In this section we will have a look at creating a test that can move between windows.

1.      Open the IDE
3.      Click on Chapter 1
4.      Click on the element “Click this to launch another window”
5.      A small window will appear where you can even verify the text.

How to store an information from the page in the test?

1.      Open the IDE and launch the site : chapter 1
2.      Right click on any text that you need to store in the text box available in the page
3.      Select store Text
4.      A dialog box will appear and ask you to enter the name of the variable
5.      Enter a variable name eg: abc
6.      Now stop recording
7.      Click on the next blank step where the steps are recording
8.      Type: Type in the command
9.      Type: storeinput in the target
10.  Type: ${abc} in the value
11.  Now run the test
12.  You can view the selected text in the text box.

Note: in the target I asked you to type storeinput which is nothing but the id of the text box.

How to find the ID?
In the Mozilla Firefox you should have installed the firebug and fire path. Go to the chapter 1 page press F12. Where using the Locator you can get the id or name or link or css or class which are nothing but the xpath.

What is X path?
The x path is nothing but the Location of the element. Each element in the page has its unique id. Example: Like our address. The address of the element is called as the ID.

For detailed ppt for Selenium IDE, kindly visit:
http://www.slideshare.net/Aneshare/selenium-over


Wednesday, 4 June 2014

Static Techniques


Definition: Testing of a system at specification level, without execution of that software.

How can we evaluate or analyze???
        1.      Requirement documents
        2.      Design document
        3.      Test plan
        4.      User manual
        5.      Examine the source code before execution

The static technique provides a powerful way to improve the quality and Productivity of software development.

To have a clear picture let me differentiate the techniques:
Static Techniques
Dynamic Techniques
Work products are examined manually or with a set of tools but not executed.
Execution involves.
Example: Reviews and inspection
Example: Specification based testing
Static testing is about prevention of defects
Dynamic testing is about finding and fixing the defects
Before compilation
After compilation
Cost of finding defects and fixing is less
Cost of finding and fixing defects is high
More reviews  comments are highly recommended for good quality
More defects are highly recommended for good quality
Static testing involves checklist and process to be followed
Dynamic testing involves test cases for execution
Verification process
Validation Process
Requires lots of meetings
Lesser meetings

COMPARED TO DYNAMIC TESTING, IT FINDS DEFECTS RATHER THAN FAILURES

Types of defects that are easier to find in the Static technique is
                 1.      Deviations from standards
                 2.      Missing requirements
                 3.      Design defects
                 4.      Non maintainable code
                 5.      Inconsistent interface specification

VARIOUS ADVANTAGES OF STATIC TESTING
      1.      Since static testing can be start early in the life cycle
                               ·         Early feedback on quality can be established
                ·         Early validation of user requirements
                ·         And not just late in the life cycle during acceptance testing
      2.      Rework cost are mostly low
      3.      When rework is reduced substantially the productivity is achieved
      4.      Additionally, exchange of information between participants
      5.      Increased awareness in Quality

The static testing process to the development process allows for process improvement, which supports the avoidance of similar errors being made in the future.

STATIC TECHNIQUE PROCESS

REVIEW PROCESS
The reviews vary from very informal to formal.

Informal Review- Not based on a formal procedure ie. No documentation

Formal Review- A review characterized by documented procedures and requirements.

THE PHASES OF FORMAL REVIEW
It follows a formal process, which are Planning, Kick-off, Preparation, Review meeting, Rework and Follow-up.

PLANNING
·         The review process begins with a request with a ‘Request for Review’ by the author to the moderator.
·         A moderator is often assigned to take care of scheduling of the review.
·         Planning needs to allow time for review and rework activities for thoroughly participate in the reviews
·         Moderator should always perform an entry check and defines at this stage formal exit criteria

Entry check:
   ü  A short check of a product sample by the moderator does not reveal a large number of majar defects
   ü  Document should be available with line numbers
   ü  Document has been cleaned up by running any automated checks that apply
   ü  Reference needed for the inspections are stable and available
   ü  Document author is prepared to join the review team and feels confident with the quality of the document

The following focuses can be identified: ie focuses on the following,
           1.      High level document – does the design fulfill to the requirements
           2.      Standards – Internal consistency, clarity, naming conventions, templates
           3.      Related documents – interface
           4.      Usage – testability or maintainability

KICK-OFF
·         It’s an Optional step in the review process
·         A short introduction on the objectives of the reviews and the documents
·         The relationship between the document and other related documents are explained if the number of related documents is high
·         Role assignment, checking rate, the pages to be checked, process changes are discussed

PREPARATION
·         The individual participants identify defects, questions and comments, according to their understanding of the document and role
·         All mistakes are recorded preferably using a logging form. Spelling mistakes are recorded but not mentioned during the meeting
·         Using checklist during this phase can make review more effective and efficient
·         A critical success for a thorough preparation is the number of pages checked per hour it is called checking rate

REVIEW MEETING
                  ·         The moderator usually played by the manager leads the meeting and set the agenda
                  ·         The creator of the documents under review plays the role of the author, who reads and invites comments
                  ·         The task of the reviewer is to communicate the defect in the work product
                  ·         The meeting participant plays the role of Scribe will note down the defects and suggestions
                  ·         The reviewer can also suggest to share it via facebook or other social media and the moderator will check and with the client and tell whether to accept or not
                  ·         Finally reviews are noted

Participants are:
The author, The moderator, The Scribe or Recorder and The Reviewer.

REWORK
The author will make changes in the document as per the reviews comments

FOLLOW UP
The moderator will circulate the reworked document to all review participants to ensure that all the changes have been included satisfactorily.

TYPES OF REVIEWS

Walk Through: which is led by author
Technical Review: Which is led by the trained moderator with no management participation
Inspection: Which is led by the trained moderator and uses entry and exit criteria

ENTRY CRITERIA
The entry criteria defines when to start testing,
   ü  Test environment availability and readiness
   ü  Test tools are ready
   ü  Test code availability
   ü  Test data availability

EXIT CRITERIA
The exit criteria defines when to stop testing activities,
   ü  When we attained enough confidence and no critical defects
   ü  When all requirements are satisfied
   ü  When time is less – Example: Product’s  delivery date is very nearby
   ü  When we don’t have sufficient budget to test the product that is lack of Cost