0% found this document useful (0 votes)
58 views

SQE Assignment 1

Uploaded by

Kiran
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

SQE Assignment 1

Uploaded by

Kiran
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Assignment 1

Course Title: Software Quality Engineering


Course Code: SWE-632

INSTRUCTOR:

Mam Iqra Rasheed


SUBMITTED BY:

Mubeen (2021-2025)
521216
BS (IT) 7th Morning

Table of Content
s
Test-Driven Development (TDD):.................................................................................................................1
Core principle:.........................................................................................................................................1
Pros of TDD:.............................................................................................................................................1
Cons of TDD:............................................................................................................................................1
Influence on software quality:.................................................................................................................1
Behavior-Driven Development (BDD):.........................................................................................................1
Core principle:.........................................................................................................................................1
Pros of BDD:.............................................................................................................................................1
Cons of BDD:............................................................................................................................................1
Influence on software quality:.................................................................................................................1
Acceptance Test-Driven Development (ATDD):............................................................................................2
Core principle:.........................................................................................................................................2
Pros of ATDD:...........................................................................................................................................2
Cons of ATDD:..........................................................................................................................................2
Influence on software quality:.................................................................................................................2
Comparison and Contrast:...........................................................................................................................2
Conclusion:..................................................................................................................................................2
Model-Based Testing and FSMs...............................................................................................................3
Example:..................................................................................................................................................3
Consider a login system with the following states:..................................................................................3
The transitions between these states might be:......................................................................................3
To test this system using model-based testing with FSMs:..........................................................................3
1. Create an FSM..................................................................................................................................3
2. Generate test cases:........................................................................................................................4
3. Execute test cases:...........................................................................................................................4
Benefits of using FSMs in model-based testing:..........................................................................................4
Control-Flow vs. Dataflow-Based Testing.................................................................................................4
Primary Objectives:.....................................................................................................................................4
Control-Flow-Based Testing:...................................................................................................................4
Dataflow-Based Testing:.........................................................................................................................5
Example:......................................................................................................................................................5
Python code.............................................................................................................................................5
Identifying Defects:.................................................................................................................................6
Question # 1:
Compare and contrast the following software testing philosophies: Test-Driven Development
(TDD), Behavior-Driven Development (BDD), and Acceptance Test-Driven Development
(ATDD). Discuss the pros and cons of each approach and how they influence software quality
Answer: Here is a comprehensive comparison and contrast of the three testing philosophies:

Test-Driven Development (TDD):


Core principle: Write a failing unit test before writing production code.
Pros of TDD:
o Ensures high-test coverage and early detection of defects.
o Promotes clean, modular (Customizable), and maintainable code.
o Encourages continuous refactoring (improving the internal structure of code without changing its
external behavior).
Cons of TDD:
o Can be time-consuming for larger projects.
o Requires a disciplined approach and a strong understanding of unit testing.
o May not always be suitable for all types of projects.
Influence on software quality:
o TDD leads to higher quality software by ensuring that code is well tested, maintainable, and free
from defects.
o It also promotes a more iterative and agile development process.

Behavior-Driven Development (BDD):


Core principle: Define the desired behavior of the software using plain language
examples.
Pros of BDD:
o Facilitates communication between stakeholders, developers, and testers.
o Ensures that the software meets the business requirements.
o Promotes collaboration and shared understanding.
Cons of BDD:
o Can be more time-consuming than TDD.
o Requires a strong understanding of the domain and business requirements.
o May not be suitable for all types of projects.
Influence on software quality:
o BDD leads to higher quality software by ensuring that it meets the business needs and is easy to
understand.

1
o It also promotes a more collaborative and customer-centric development process.

Acceptance Test-Driven Development (ATDD):


Core principle: Write acceptance tests before development starts to define the acceptance
criteria.
Pros of ATDD:
o Ensures that the software meets the customer's expectations.
o Provides a clear definition of done.
o Facilitates early feedback and reduces the risk of rework.
Cons of ATDD:
o Can be time-consuming to write acceptance tests.
o May require additional tools and processes.
o May not be suitable for all types of projects.
Influence on software quality:
o ATDD leads to higher quality software by ensuring that it meets the customer's requirements and
is fit for purpose.
o It also promotes a more customer-centric and risk-based development process.

Comparison and Contrast:

Feature TDD BDD ATDD


Focus Unit testing Behavior Acceptance testing
Level Code level Feature level System level
Primary goal Ensure code Meet business requirements Meet customer
correctness expectations
Communication Developers Stakeholders, developers, testers Stakeholders, developers
Tools Unit testing BDD frameworks (Cucumber, Spec Test automation tools
frameworks Flow)

Conclusion:
All three testing philosophies have their own strengths and weaknesses, and the best approach
will depend on the specific needs of the project. TDD is well suited for ensuring code quality,
BDD is good for aligning development with business requirements, and ATDD is effective for

2
ensuring customer satisfaction. In many cases, a combination of these approaches can be used to
achieve the highest possible level of software quality.

Question # 2:
Describe model-based testing and explain how finite state machines (FSMs) are used in this
approach. Provide an example where FSM can be applied to test a login system with multiple
states such as "Logged In," "Logged Out," and "Locked Account."
Answer:

Model-Based Testing and FSMs


Model-Based Testing is a testing approach where a formal model of the system under test is
created. This model is then used to generate test cases automatically. This approach is
particularly effective for complex systems with many states and transitions.
Finite State Machines (FSMs) are mathematical models that represent systems with a finite
number of states and transitions between those states. They are often used in model-based testing
to represent the behavior of a system.
Example: Testing a Login System with FSMs
Consider a login system with the following states:
 Logged In
 Logged Out
 Locked Account
The transitions between these states might be:
 Logged Out to Logged In (successful login)
 Logged In to Logged Out (logout)
 Logged In to Locked Account (multiple failed login attempts)
 Locked Account to Logged Out (after a specified time period)
An FSM can be created to represent this behavior. The FSM would have three nodes (states) and
transitions between them based on the login system's rules.

3
To test this system using model-based testing with
FSMs:
1. Create an FSM: Construct an FSM that accurately represents the login system's states and
transitions.
2. Generate test cases: Use a tool to automatically generate test cases based on the
FSM. These test cases would cover different paths through the system, ensuring that all possible
states and transitions are tested.
3. Execute test cases: Run the generated test cases against the login system to identify
defects.

Benefits of using FSMs in model-based testing:


 Automation: Test cases can be generated automatically, reducing the time and effort required for
testing.
 Thoroughness: FSMs can help ensure that all possible states and transitions are tested,
improving test coverage.
 Clarity: FSMs provide a clear and concise representation of the system's behavior, making it
easier to understand and communicate.
 Reusability: FSMs can be reused for different testing activities, such as regression testing.
By using model-based testing with FSMs, organizations can improve the quality and reliability
of their software systems.

Question # 3:
Compare control-flow based testing with dataflow-based testing. What are the primary objectives
of each method? Use a simple code example to illustrate how these two testing techniques differ
in identifying defects.
Answer:

Control-Flow vs. Dataflow-Based Testing


Control-Flow-Based Testing focuses on the sequence of statements executed in a program. It
aims to ensure that all possible paths through the code are tested. This technique is particularly
effective for identifying logical errors and structural defects.

4
Dataflow-Based Testing focuses on the values that flow through the program. It aims to ensure
that all possible data values are handled correctly. This technique is effective for identifying
errors related to data manipulation, such as incorrect calculations or data type mismatches.

Primary Objectives:
Control-Flow-Based Testing:
o Ensure that all possible paths through the code are executed.

o Identify logical errors, structural defects, and missing branches.


Dataflow-Based Testing:
o Ensure that all possible data values are handled correctly.
o Identify errors related to data manipulation, such as incorrect calculations or data type
mismatches.

Example:
Consider the following simple function:

Python code
def calculate_average(numbers):
sum = 0
count = 0

for number in numbers:


sum += number
count += 1

if count == 0:
return None
else:
return sum / count
Control-Flow-Based Testing:
 Would focus on testing different paths through the function, such as:

o The path where the numbers list is empty.


o The path where the numbers list contains one or more elements.
o The path where the numbers list contains negative numbers.
Dataflow-Based Testing:
 Would focus on testing different data values, such as:

5
o A list of integers.

o A list of floating-point numbers.

o A list containing a mix of integers and floating-point numbers.

o A list with a large number of elements.

o A list with a small number of elements.


Identifying Defects:
 Control-Flow-Based Testing might identify a defect if the function incorrectly handles an empty
list or a list with negative numbers.
 Dataflow-Based Testing might identify a defect if the function incorrectly calculates the average
for certain data values, such as when dealing with very large or very small numbers.
In summary, control-flow-based testing is effective for identifying structural issues, while
dataflow-based testing is effective for identifying data-related issues. In practice, a combination
of both techniques is often used to ensure thorough testing of software systems.

You might also like