0% found this document useful (0 votes)
565 views13 pages

ST Practical Questions Complete

Here are test cases for the program using branch, decision, and path coverage: Branch Coverage: 1. x = 1 2. x = -1 Decision Coverage: 1. x = 2 2. x = 3 Path Coverage: 1. x = 2 2. x = -2 3. x = 1 This covers all branches, decisions, and paths in the program.

Uploaded by

Jayshree Ahirrao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
565 views13 pages

ST Practical Questions Complete

Here are test cases for the program using branch, decision, and path coverage: Branch Coverage: 1. x = 1 2. x = -1 Decision Coverage: 1. x = 2 2. x = 3 Path Coverage: 1. x = 2 2. x = -2 3. x = 1 This covers all branches, decisions, and paths in the program.

Uploaded by

Jayshree Ahirrao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

ST PRACTICAL-1

2
3
4

You have got the brilliant idea of setting up a company that sells testing services to software
houses. Make a strategic plan for your company, taking into account the following issues:

What is the testing process that will be followed in the company?


What is the focus of the testing services?
What kind of people are you going to hire as staff for the company?
How are you going to validate that a testing project carried out in the company has been
beneficial to the customer?
What kind of automated tools will the company use?
Title: Write a Test Plan
Problem Statement:
Prepare a small project and submit SRS, design, coding and test plan.
The NextDate problem is a function of three variables: day, month and year. Upon the input of a
certain date it returns the date of the day after that of the input.Design test cases for testing the
program with the boundary value and equivalence partitioning strategy.
The triangle problem accepts three integers (a, b and c)as its input, each of which are
taken to be sides of a triangle. The values of these inputs are used to determine the type
of the triangle (Equilateral, Isosceles, Scalene or not a triangle).
For the inputs to be declared as being a triangle they must satisfy the six conditions:
C1. 1 a 200.
C2. 1 b 200.
C3. 1 c 200.
C4. a < b + c.
C5. b < a + c.
C6. c < a + b.
Otherwise this is declared not to be a triangle.
The type of the triangle, provided the conditions are met, is determined as follows:
1. If all three sides are equal, the output is Equilateral.
2. If exactly one pair of sides is equal, the output is Isosceles.
3. If no pair of sides is equal, the output is Scalene.
Design test cases for testing the program with boundary value analysis and equivalence class
partitioning.

ST PRACTICAL-2
1 A store in city offers different discounts depending on the purchases made by the individual.
In order to test the software that calculates the discounts, we can identify the ranges of
purchase values that earn the different discounts. For example, if a purchase is in the range of
$1 up to $50 has no discounts, a purchase over $50 and up to $200 has a 5% discount, and
purchases of $201 and up to $500 have a 10% discounts, and purchases of $501 and above
have a 15% discounts.
2 The program reads an arbitrary number of temperatures (as integer numbers) within the range
60C +60C and prints their mean value. Design test cases for testing the program with the
black-box strategy.
3 When getting a persons weight and height as input, the program prints the persons body
weight
index. The weight is given in kilograms (as a real number, for instance: 82,0) and the height in
meters (as a real number, for instance: 1,86). The body weight index equals weight divided by
height squared: weight / (height height). Design test cases for testing the program with the
black-box strategy.
4 Develop decision tableandWrite test cases for fixed deposit interest calculations with
following conditions.

1. The branch cannot accept more than 5,00,000 deposit in single name.
2. The minimum balance is Rs 1000/5
Design the test cases for Boundary Value analysis of the following.
Consider a program that prompts the user to input three numbers (say x, y, z) and the data
type for input parameters ensures that these will be integers greater than 0 and less than or
equal to 100. The program should then output the numbers in ascending order.
Design the test cases for Equivalence Partitioning for question 1.
6
Design the test cases for Boundary Value analysis of the following.
Consider a program for determining the largest amongst three numbers. Its input is a triple
of integers and the numbers are in [1, 300]. The possible outputs would be largest amongst
three numbers or invalid input.
7 The NextDate problem is a function of three variables: day, month and year. Upon the input of
a certain date it returns the date of the day after that of the input.Design test cases for testing
the program with decision table strategy.
The triangle problem accepts three integers (a, b and c)as its input, each of which are
taken to be sides of a triangle. The values of these inputs are used to determine the type
of the triangle (Equilateral, Isosceles, Scalene or not a triangle).
For the inputs to be declared as being a triangle they must satisfy the six conditions:
C1. 1 a 200.

C2. 1 b 200.
C3. 1 c 200.
C4. a < b + c.
C5. b < a + c.
C6. c < a + b.
Otherwise this is declared not to be a triangle.
The type of the triangle, provided the conditions are met, is determined as follows:
1. If all three sides are equal, the output is Equilateral.
2. If exactly one pair of sides is equal, the output is Isosceles.
3. If no pair of sides is equal, the output is Scalene.
Design test cases for testing the program with decision table strategy

ST PRACTICAL-3
1

3
4
5

Let us study the following program:


x=0; read(y);
while (y > 100) { x=x+y; read(y); }
if (y < 200) print(x) else print(y);
a) Construct a control-flow graph for the program.
b) Design test cases for reaching complete branch coverage over the program. Use as few
test cases as possible.
Consider the following program.Write the test cases which will give
100% statement coverage
100% path coverage
100% decision coverage for the following program
Read P
Read Q
If P+Q>100 Then
Print Large
EndIF
If P>50 Then
Pring P Large
EndIf
Write the program to find the largest of three numbers.Draw the program graph
Write test cases that cover all statements and all branches
Write the program for triangle problem.Draw the program graph
Write test cases that cover all statements and all branches
Consider the following code:
1. int main (int MaxCols, int Iterations, int MaxCount)
2. {
3. int count = 0, totals[MaxCols], val = 0;
4. memset (totals, 0, MaxCols * sizeof(int));
5. count = 0;
6. if (MaxCount > Iterations)
7. {
8. while (count < Iterations)
9. {
10. val = abs(rand()) % MaxCols;
11. totals[val] += 1;
12. if (totals[val] > MaxCount)
13. {
14. totals[val] = MaxCount;
15. }
16. count++;
17. }
18. }
19. return (0);
20.}
a. Create a directed control-flow graph for this code.
b. Calculate the cyclomatic complexity.
c. List the basis test paths that should be tested

ST PRACTICAL-4
1

An insurance agency has the following norms fixed to provide premium for its policy holders.
If age<=25 and no claim has been made , premium increase will be $50 ,else $25
If age<=25 and number of claims is one ,premium increase will be $100,else $50
If age<=25 and number of claims is 2-4 ,premium increase will be $400,else $200
If one or more claims are made, send warning letter.If the number of claims made is 5 or more
,cancel policy
Draw the decision table and cause effect graph for the insurance renewal
For the following liability procedure ,design test cases using branch ,condition ,decision and
multiple decision coverage
Procedure Liability(Age ,Gender,Married,Premium)
Begin
Premium=500;
If (Age<25) and (Gender=Male) and(not Married) Then
Premium=Premium+1500
Else(if (Married or Gender=Female)) Then
Premium=Premium-200;
If(Age>45 ) and (Age<65) Then
Premium=Premium-100;
End;
The software responds to input requests to change the display mode for a time display device
.The display mode can be set to one of the four values:
Two corresponding to display either time or date.
The other two when altering either time or date.
Four possible input requests:
Change mode(CM)
Reset(R )
Time Set(TS)
Data Set (DS)
Change Mode (CM):
Activation of this shall cause the display mode to move between Display Time(T) and Display
Date(D)
Reset(R )
If display mode is set to T or D ,then a reset shall cause the display mode to be set to Alter
time(AT) or Alter Date (AD) modes
Time Set (TS)
Activation of this shall cause the display mode to return to T from AT
Date Set(DS)
Activation of this shall cause the display mode to return to D from AD
Draw the state transition diagram,possible transitions table ,State table and write the test cases
Consider the program to find the largest amongst three numbers. Find all du
paths and identify those du-paths that are definition clear. Also find all du-paths,
all uses and all-definitions and generate test cases.

ST PRACTICAL-5
1

For the following program, draw the path coverage diagram ,determine cyclomatic
complexity write the basis paths to be tested and the test cases
Euclid(int m,int n)
0 Int r;
1 if (n>m) {
2 r=m;
3 m=n;
4 n=r;
5 }
6 r=m%n;
7 while (r !=0){
8 m=n;
9 n=r;
10 r=m%n;
11 }
12 return n;
13 }
Consider a program for the determination of division of a student based on the marks in
three subjects. Its input is a triple of positive integers (say mark1, mark2, and mark3)and
values are from interval [0, 100].
The division is calculated according to the following rules:
Marks Obtained
Division
(Average)
75 100
First Division with distinction
60 74
First division
50 59
Second division
40 49
Third division
0 39
Fail
Total marks obtained are the average of marks obtained in the three subjects i.e.
Average = (mark1 + mark 2 + mark3) / 3
The program output may have one of the following words:
[Fail, Third Division, Second Division, First Division, First Division with Distinction]
Draw the program graph and the DD path graph.
Find cyclomatic complexity and also find independent paths.
A tourist of age greater than 21 years and having a clean driving record is supplied a
rental car. A premium amount is also charged if the tourist is on business, otherwiseit is
not charged.
If the tourist is less than 21 year old, or does not have a clean driving record, the system
will
display the following message: Car cannot be supplied
Draw the cause-effect graph and generate test cases.
For the following program , design test cases using branch ,decision and path coverage
foo(int x) {
if (x>0) {
// clap
} else {
// stump
}
if (x is even) {
// dance
} else {
// sing

}
5

}
For the following procedure ,draw the control flow graph .Design test cases using
statement ,branch, path, simple condition and multiple condition coverage
void countChar (int& vocNumber, int& totalNumber){
char chr;
cin>> chr;
while ((chr >=`A ) && (chr <=`Z ) && (totalNumber <INT_MAX)){
totalNumber +=1;
if ((chr ==`A )||(chr ==`E ) ||(chr ==`I ) ||(chr ==`O ) ||(chr ==`U )){
vocNumber +=1;}
cin>> chr
}
}

ST PRACTICAL-6
1

0.
1.
2.
3.

Void quad_eqn(float A,B,C ,Boolean Is_Complex)


{ float Discrim = B*B - 4*A*C;
Float R1,R2;
{

4.
5.
6.
7.
8.
9.

If ( Discrim<0.0) )
Is_Complex=true;
Else
Is_Complex=false;
Endif;
If not Is_Complex

10. R1=( -B +sqrt(Discrim)) / (2.0*A);


11. R2=( -B -sqrt(Discrim)) / (2.0*A);
12. Endif;
13. End quad_eqn; }
14. }
For the above function, draw the following tables and write the test cases:
a) Occurance of variables and their categories
b) du pairs and their type
c) All c-uses
d) All p-uses
2

For the above function, draw the following tables and write the test cases:
a) Occurance of variables and their categories
b) du pairs and their type
c) All c-uses
d) All p-uses
3 Consider the program for the determination of the division problem. Its input is
a triple of positive integers (mark1, mark2, mark3) and values for each of these
may be from
interval [0, 100].. The output may have one of the options given below:
(i) Fail
(ii) Third division
(iii) Second division
(iv) First division
(v) First division with distinction
(vi) Invalid marks
Find all du-paths and identify those du-paths that are definition clear. Also find all
du-paths,
all-uses and all-definitions and generate test cases for these paths.

ST PRACTICAL-7

1 Scenario: If you take the train before 9:30 am or in the afternoon after 4:00 pm until 7:30
pm ('the rush hour'),you must pay full fare. A saver ticket is available for trains between
9:30 am and 4:00 pm, and after 7:30 pm.What are the partitions and boundary values to
test the train times for ticket types? Which are valid partitions and which are invalid
partitions? What are the boundary values? (A table may be helpful to organize your
partitions and boundaries.) Derive test cases for the partitions and boundaries.
2 Scenario: If you hold an 'over 60s' rail card, you get a 34% discount on whatever ticket
you buy. If you are traveling with a child (under 16), you can get a 50% discount on any
ticket if you hold a family rail card,otherwise you get a 10% discount. You can only hold
one type of rail card.
Produce a decision table showing all the combinations of fare types and resulting
discounts and derive test cases from the decision table.
3 Scenario: A website shopping basket starts out as empty. As purchases are selected, they
are added to the shopping basket. Items can also be removed from the shopping basket.
When the customer decides to check out, a summary of the items in the basket and the
total cost are shown, for the customer to say whether this is OK or not. If the contents
and price are OK, then you leave the summary display and go to the payment system.
Otherwise you go back to shopping (so you can remove items if you want).
a. Produce a state diagram showing the different states and transitions. Define
a test, in terms of the sequence of states, to cover all transitions.
b. Produce a state table. Give an example test for an invalid transition.
4 Scenario: A vending machine dispenses either hot or cold drinks. If you choose a hot
drink (e.g. tea or coffee), it asks if you want milk (and adds milk if required), then it asks
if you want sugar (and adds sugar if required), then your drink is dispensed.
a. Draw a control flow diagram for this example. (Hint: regard the selection of the
type of drink as one statement.)
b. Given the following tests, what is the statement coverage achieved? What is the
decision coverage achieved?
Test 1: Cold drink
Test 2: Hot drink with milk and sugar
c. What additional tests would be needed to achieve 100% statement coverage? What
additional tests would be needed to achieve 100% decision coverage?

ST Practical-8
1
2
3

Test Automation using Selenium IDE


Automate web test using Selenium IDE and Firebug.
Design a web page with a two text boxes and two buttons. Write Selenium Script
using IDE to enter Username and password and click the submit button. After the
submit button is clicked, redirect it to the new page and compare its title. If the
title matches, display the message Title matched in the output window.

4
5

Generate Java Web driver code of the same.


Test Automation using Selenium Webdriver (Title Match)
Design an HTML form. Write Selenium webdriver to automate the form filling

process.
Design an HTML form. Write Selenium webdriver to display the tag name for a

particular control on the form.


Design a web page with a button. On the click of the button a message box should
be displayed with a message. Write a selenium web driver script to capture the
test in the message box and display the text in the output window

You might also like