0% found this document useful (0 votes)
105 views19 pages

Stqa Practical

dd

Uploaded by

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

Stqa Practical

dd

Uploaded by

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

COMPUTER SCIENCE AND ENGINEERING

FACULTY OF ENGINEERING AND TECHNOLOGY


STQA (203105396) B.Tech. 7th SEM

PRACTICAL 1

AIM :

Design test cases using Boundary value analysis.

DESCRIPTION:
 Boundary Value Analysis (BVA) is a black-box testing technique used to identify defects in
software by focusing on the edges (boundaries) of input values. The assumption is that
errors are more likely to occur at the extremes or near the borders of valid and invalid input
ranges.

THEORY:

 Boundary Value Analysis (BVA): Unveiling Errors at the Edges


 Boundary Value Analysis (BVA) is a black-box testing technique that plays a crucial
role in safeguarding software quality. It operates under the assumption that software
defects are more likely to occur at the fringes, or boundaries, of acceptable input
values. By meticulously designing test cases that target these boundary areas, BVA
helps us identify critical bugs and ensure the software behaves as intended across
various input scenarios.

CODE:

n = int(input("Type the no. of test cases: "))


o = int(input("Type the minimun range: "))
p = int(input("Type the maximum range: "))
for i in range(n):
s = int(input("Type the value: "))
print("Value Valid Test-Case", i + 1)

1
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

if s >= o and s <= p:


print(s, " yes pass")
else:
print(s, " no fail")

OUTPUT:
Type the no. of test cases: 5
Type the minimun range: 5
Type the maximum range: 10

VALUE VALID TEST CASE

10 Yes Pass

15 No Fail

5 Yes Pass

56 No Fail

2 No Fail

2
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

PRACTICAL 2
AIM:

Design test cases using Equivalence class partitioning.

DESCRIPTION:

Equivalence Classes: Divide the input domain into classes based on expected behavior:

 Valid Length: Class containing OTPs with the exact expected length (e.g., 6 digits).
 Invalid Length: Two classes - one for OTPs shorter and another for OTPs longer
than the expected length.
 Valid Content: Class containing OTPs composed of allowed characters (e.g., digits
0-9).
 Invalid Content: Multiple classes depending on restrictions:

Class for OTPs containing non-numeric characters (alphabetic, special


characters)
 Class for OTPs containing only whitespace characters (spaces, tabs)
 Additional classes for specific restrictions like leading zeroes
(allowed/disallowed)
 Case Sensitivity (if applicable):
 Two classes - one for OTPs entered entirely in uppercase and another
for lowercase.
 One class for OTPs with a mix of upper and lowercase characters (if
treated as invalid).
 Whitespace (if applicable):
 Class for OTPs with no whitespace characters.
 Class for OTPs containing any whitespace characters.

 Test Case Design: For each equivalence class, design at least one test case with a
representative input value. The test case should verify that the function behaves as
expected for that class (valid or invalid OTP).

OTP Validation Test Cases using Equivalence Class Partitioning (ECP)

THEORY:

 Equivalence Class Partitioning (ECP) is a black-box testing technique used to divide


the input domain of a function (in this case, OTP validation) into classes where all

3
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

elements within a class are expected to behave similarly. This allows us to design a
smaller set of test cases that effectively cover a wider range of scenarios.

CODE:

valid_lengths = {4, 6}

test = int(input("Enter the number of test cases: "))

res = []
for _ in range(test):
otp = input("Enter your OTP: ")
res.append(otp)

print("Test-Case | Enter-Value | Valid | Invalid | Pass/Fail")

for idx, otp in enumerate(res, start=1):


if len(otp) in valid_lengths:
Valid = "Yes"
Invalid = "No"
Pass = "Pass"
else:
Valid = "No"
Invalid = "Yes"
Pass = "Fail"

print(f"{idx:<9} | {otp:<12} | {Valid:<5} | {Invalid:<7} | {Pass}")

4
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

OUTPUT:

TABLE:

TEST CASE VALUE VALID INVALID PASS/FAIL

1 123456 YES NO PASS

2 1233 YES NO PASS

3 466666 NO YES FAIL

5
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

PRACTICAL -3
AIM: Design independent paths by calculating cyclometric complexity using date problem.
Theory: Cyclomatic Complexity may be defined as:
• It is a software metric that measures the logical complexity of the program code.
• It counts the number of decisions in the given program code.
• It measures the number of linearly independent paths through the program code.
Cyclomatic complexity indicates several information about the program code Cyclomatic
Complexity Meaning 1 – 10 • Structured and Well Written Code
• High Testability
• Less Cost and Effort 10 – 20
• Complex Code
• Medium Testability
• Medium Cost and Effort 20 – 40
• Very Complex Code
• Low Testability
• High Cost and Effort > 40
• Highly Complex Code
• Not at all Testable
• Very High Cost and Effort Importance of Cyclomatic Complexity-

• It helps in determining the software quality.


• It is an important indicator of program code’s readability, maintainability and portability.
• It helps the developers and testers to determine independent path executions.
• It helps to focus more on the uncovered paths.
• It evaluates the risk associated with the application or program.
• It provides assurance to the developers that all the paths have been tested at least once.
Properties of Cyclomatic Complexity-

6
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

• It is the maximum number of independent paths through the program code.


• It depends only on the number of decisions in the program code.
• Insertion or deletion of functional statements from the code does not affect its cyclomatic
complexity.
• It is always greater than or equal to 1.
Cyclomatic Complexity = E – N + 2
Here-
• E = Total number of edges in the control flow graph
• N = Total number of nodes in the control flow graph
Example 1: Calculate cyclomatic complexity for the given code
{int i,j,k;
For(i=0;i<=N;i++)
P[i]=1;
For(i=2;i<=N;i++)
{
K=p[i];j=1;
While(a[p[j-1]]>a[k]){
P[j]=p[j-1];
j--;
}
P[j]=k;
}}

Solution We draw the following control flow graph for the given code

7
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

Solution :
We draw the following control flow graph for the given code

8
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

9
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

PRACTICAL -4

AIM:
Design test cases using Decision table Design independent paths by taking DD
path using date problem.

Theory:
A Decision Table is a tabular representation of inputs versus rules/cases/test
conditions. It is a very effective tool used for both complex software testing and
requirements management. Decision table helps to check all possible combinations
of conditions for testing and testers can also identify missed conditions easily. The
conditions are indicated as True(T) and False(F) values.
Decision table testing is a software testing technique used to test system behavior for
different input combinations. This is a systematic approach where the different input
combinations and their corresponding system behavior (Output) are captured in a tabular
form. That is why it is also called as a Cause-Effect table where Cause and effects are
captured for better test coverage.
Let's learn with an example.
Example 1: Credit card example:
Let’s take another example. If you are a new customer and you want to open a credit card
account then there are three conditions first you will get a 15% discount on all your
purchases today, second if you are an existing customer and you hold a loyalty card, you
get a 10% discount and third if you have a coupon, you can get 20% off today (but it can’t
be used with the ‘new customer’ discount).
Discount amounts are added, if applicable. This is shown in Table

10
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

the conditions and actions are listed in the left hand column. All the other columns in the decision
table each represent a separate rule, one for each combination of conditions.

We may choose to test each rule/combination and if there are only a few this will usually be
the case. However, if the number of rules/combinations is large we are more likely to
sample them by selecting a rich subset for testing.
Now let’s see the decision table for credit card shown above:
• Note that we have put X for the discount for two of the columns (Rules 1 and 2) –
this means that this combination should not occur. You cannot be both a new
customer and also holding a loyalty card as per the conditions mentioned above.
Hence there should be an error message stating this.
• We have made an assumption in Rule 3. Since the coupon has a greater discount
than the new customer discount, we assume that the customer will choose 20%
rather than 15%. We cannot add them, since the coupon cannot be used with the
‘new customer’ discount as stated in the condition above. The 20% action is an
assumption on our part, and we should check that this assumption (and any other
assumptions that we make) is correct, by asking the person who wrote the
specification or the users.
• For Rule 5, however, we can add the discounts; since both the coupon and the
loyalty card discount should apply (that’s our assumption).
• Rules 4, 6 and 7 have only one type of discount and Rule 8 has no discount, so 0%.
If we are applying this technique thoroughly, we would have one test for each column or
rule of our decision table. The advantage of doing this is that we may test a combination of
things that otherwise we might not have tested and that could find a defect.
However, if we have a lot of combinations, it may not be possible or sensible to test every
combination. If we are time-constrained, we may not have time to test all combinations.
Don’t just assume that all combinations need to be tested.
It is always better to prioritize and test the most important combinations. Having the full
table helps us to decide which combinations we should test and which not to test this time.
In the example above all the conditions are binary, i.e. they have only two possible values:

11
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

True or False (or we can say Yes or No).


Design independent paths by taking DD path using date problem
To draw a Flow Graph, a DD Graph, calculation of Cyclomatic Complexity V(G) and find
out
all independent paths from the DD paths graph, for the case of a triangle wherein the
program reads the three sides of a triangle (say a, b, c). The output may be Scalene
triangle or a Isosceles triangle or an equilateral or might be a triangle at all.

Code:
decision_table = [
{"credit_score": "good ", "income_level": "high", "collataral": "yes", "request_status":
"Approve Loan"},
{"credit_score": "good", "income_level": "high", "collataral": "no", "request_status":
"Approve Loan"},
{"credit_score": "good", "income_level": "low", "collataral": "yes", "request_status":
"Reject Loan"},
{"credit_score": "good", "income_level": "low", "collataral": "no" ,"request_status":
"Approve Loan"},
{"credit_score": "bad", "income_level": "high", "collataral": "yes", "request_status":
"Approve Loan"},
{"credit_score": "bad", "income_level": "high", "collataral": "no", "request_status":
"Reject Loan"},
{"credit_score": "bad", "income_level": "low", "collataral": "yes","request_status": "Reject
Loan"},
{"credit_score": "bad", "income_level": "low", "collataral": "no", "request_status": "Reject
Loan"}
]
def loan_approval(credit_score,income_level,collataral):
if credit_score == "good" and (income_level == "high" or collataral =="yes"):
return "Approve loan"
elif credit_score == "bad" and (income_level == "high" or collataral =="yes"):
return "Approve loan"
else:

12
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

return "Reject Loan"

def run_test_case(decision_table):
for i , test_case in enumerate(decision_table):
credit_score=test_case["credit_score"]
income_level=test_case["income_level"]
collataral=test_case["collataral"]
request_status=test_case["request_status"]
actual_result=loan_approval(credit_score,income_level,collataral)
expected_result=request_status
if actual_result == expected_result:
print("Test case {} passed".format(i+1))
else:
print("Test case {} failed".format(i+1))

# Use _name_ to check if the script is the main program


if _name_ == "_main": # Changed 'name' to 'name_'
run_test_case(decision_table)

OUTPUT:

Test case 1 failed


Test case 2 failed
Test case 3 failed
Test case 4 failed
Test case 5 failed
Test case 6 failed
Test case 7 failed
Test case 8 passed

13
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

PRACTICAL – 6

AIM :
Understand The Automation Testing Approach.

DESCRIPTION:
 Automation testing replaces manual test execution with software tools and scripts.
These scripts simulate user interactions and verify functionalities. This approach
offers significant advantages: faster testing due to automation, improved accuracy
through reduced human error, quicker bug detection through frequent test runs, and
the ability to cover complex scenarios. By incorporating different levels of automation
testing, like UI or API testing, you can achieve a more robust and efficient software
development process, ultimately leading to higher quality software.

PROCESS OF AUTOMATION TESTING:

The automation testing process can be broken down into six key stages:

1. Planning and Prioritization: This involves defining your goals, resources, and test
scope. Not all tests are ideal for automation. Here, you identify critical functionalities
and repetitive manual tests that would benefit most from being automated.
2. Tool Selection: Choosing the right automation tool depends on factors like the
application type (web, mobile, desktop) and programming languages used. Popular
options include Selenium, Cypress, Appium, etc.
3. Framework Design: Establishing a structured way to organize your tests is crucial.
This framework promotes maintainability, scalability, and reusability of your test
scripts. Consider using frameworks like Robot Framework, pytest, or even custom
solutions.
4. Test Script Development: This is where you write clear, concise, and well-
documented test scripts. Focus on testing core functionalities and user flows.
Remember, well-structured tests are easier to debug and update in the future.
5. Test Execution and Reporting: Set up a system to run your automated tests
regularly. This could be integrated into your CI/CD pipeline for frequent regression
testing. Generate comprehensive reports to analyze results and identify failures.

14
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

6. Maintenance and Improvement: Automation is an ongoing process. Regularly


review and update your test suite as the application evolves. Fix failing tests
promptly, and consider adding new tests to cover recently introduced features.

By following these steps, you can establish a robust automation testing process that improves
your software development lifecycle.

ADVANTAGES:

Here are some of the key advantages of automation testing:

 Increased Efficiency and Speed: Automation significantly reduces the time spent on
repetitive manual testing tasks.
 Improved Accuracy and Repeatability: Scripts eliminate human error and ensure
consistent test execution every time they're run.
 Faster Feedback Loop: Automated tests can be run frequently, even overnight or on
weekends.
 Enhanced Test Coverage: Automation allows you to test scenarios that might be
difficult or impractical to perform manually.
 Improved Software Quality: By catching bugs early and often through frequent
testing, automation helps to deliver higher quality software with fewer defects.
 Reduced Testing Costs: While there's an initial investment in setting up automation
tools and frameworks, the long-term benefits outweigh the costs. Reduced manual
testing efforts and faster development cycles lead to overall cost savings.

In summary, automation testing offers a faster, more reliable, and more comprehensive way
to test software, ultimately leading to higher quality applications and improved development
efficiency.

DISADVANTAGES:

Here are some of the disadvantages to consider with automation testing:

 Initial Investment: Setting up automation requires an upfront investment in tools,


training, and framework development. This can be a barrier for smaller teams or
projects with tight budgets.
 Maintenance Costs: Test scripts need to be maintained and updated as the
application evolves. This ongoing effort can be time-consuming and requires skilled
personnel.
 Not All Tests Are Automatable: Certain tests, like exploratory testing or user
experience testing, are still best suited for manual execution. Automation is most
effective for repetitive, well-defined tasks.

15
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

 False Positives and Debugging Challenges: Sometimes automated tests can fail due
to reasons unrelated to actual bugs. Debugging these failures can be complex,
especially for intricate test scripts.
 Limited Bug Detection: While automation excels at catching regressions and
functional bugs, it might miss more subtle issues like usability problems or visual
inconsistencies.

.In conclusion, while automation testing offers significant advantages, it's important to be
aware of its limitations. By carefully considering these drawbacks, you can make
informed decisions about where automation can best be applied in your software
development process.

APPLICATION:

Automation testing has a wide range of applications across various software development
areas. Here are some key examples:

 Web Applications: Automating user interactions with web interfaces for login,
search functionality, shopping cart processes, and more. This ensures consistent user
experience and catches regressions after code updates.
 Mobile Apps: Similar to web applications, automation can test user journeys, logins,
in-app purchases, and various functionalities on mobile devices.
 API Testing: Verifying how the application interacts with other systems through its
APIs. This ensures data exchange happens seamlessly and as expected.
 Desktop Applications: Automating workflows, data entry, and other functionalities
within desktop software programs.
 Performance Testing: Simulating heavy user loads to assess how the application
handles stress and maintains performance under pressure.

Practical : 7

16
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

Aim :
Using Selenium IDE, write a test suite containing minimum 4 test cases.

Theory:
 Selenium IDE TEST suite
https://procapitalacademy.com/

https://www.amazon.in/

17
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

https://www.flipkart.com/

https://paruluniversity.ac.in/

18
ENROLLMENT NO: 210305124014
COMPUTER SCIENCE AND ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
STQA (203105396) B.Tech. 7th SEM

19
ENROLLMENT NO: 210305124014

You might also like