Unit 3
Unit 3
Course Code-COM-702(B)
Lecture No-
CO1 Understand written algorithms in terms of their composite steps and transformations.
3 Illustrate the Phases of Algorithm Construction (Design, Validation, Analysis and Testing).
There are six common types of test automation frameworks, each with
their own architecture and differing benefits and disadvantages.
Definition:
A testing approach where common functions and procedures are stored in shared libraries.
These libraries are accessible to multiple test scripts, which can call the functions as needed,
thereby reducing redundancy and promoting code reusability.
Limitations of library framework
Test data is often hardcoded directly into the test scripts. This means that any changes in the
test data require modifications to the scripts themselves, which can be time-consuming and
prone to errors. It's a simple method but has the disadvantage of low flexibility and high
maintenance, especially when dealing with a large number of test cases or frequent changes
in test data.
Example: E-commerce Application Testing: Imagine a test script is written for
an e-commerce website to verify that the login functionality works as expected.
The script includes hardcoded credentials, such as a username and password.
Using a data-driven framework separates the test data from script logic,
meaning testers can store data externally.
Very frequently, testers find themselves in a situation where they need to test
the same feature or function of an application multiple times with different sets
of data. In these instances, it’s critical that the test data not be hard-coded in the
script itself, which is what happens with a Linear or Modular-based testing
framework.
Setting up a data-driven test framework will allow the tester to store and pass
the input/ output parameters to test scripts from an external data source, such as
Excel Spreadsheets, Text Files, CSV files, SQL Tables, or ODBC repositories.
The test scripts are connected to the external data source and told to read and
populate the necessary data when needed.
CSV file example: Contains rows of user credentials and the expected
accessibility or outcomes.
Test Script:
• The script reads the test data, logs in with the provided credentials, and checks
whether the user can access specific features according to their role.
Functions Library:
• Common functions used across various tests like login(), checkAccess(),
logout(), etc., stored in a library.
Test Automation Fundamentals. Unit 3
Data- driven framework- example
9
• import csv # Verify access to features
• from selenium import webdriver • result = check_access(driver, row['UserRole'])
• from user_functions_library import login, • assert result == (row['ExpectedAccess'] ==
check_access, logout 'True'), f"Access test failed for {row['UserRole']}"
•
Disadvantages
You’ll need a highly-experienced tester who is proficient in various programming
functions) that connect the tests to those external data sources seamlessly.
Data Management Overhead: Maintaining the test data can become a significant
overhead. The data files (or databases) need to be kept up-to-date and organized. As the
amount of test data grows, so does the effort required to manage it.
Increased Execution Time: Running tests with multiple sets of data can significantly
increase the total execution time for test suites. This can impact the feedback loop in
continuous integration environments where quick test results are desirable.
In a keyword-driven framework, each function of the application under test is laid out in
a table with a series of instructions in consecutive order for each test that needs to be
run.
In a similar fashion to the data-driven framework, the test data and script logic are
separated in a keyword-driven framework, but this approach takes it a step further.
With this approach, keywords are also stored in an external data table (hence the name),
making them independent from the automated testing tool being used to execute the
tests.
Keywords are the part of a script representing the various actions being performed to
test the GUI of an application. These can be labeled as simply as ‘click,’ or ‘login,’ or
with complex labels like ‘clicklink,’ or ‘verifylink.’
In the table, keywords are stored in a step-by-step fashion with an associated object, or
the part of the UI that the action is being performed on. For this approach to work
properly, a shared object repository is needed to map the objects to their associated
actions.
Once the table has been set up, all the testers have to do is write the code that will
prompt the necessary action based on the keywords. When the test is run, the test data is
read and pointed towards the corresponding keyword which then executes the relevant
script.
Disadvantages:
• The initial cost of setting up the framework is high. It is time-consuming and complex.
The keywords need to be defined and the object repositories / libraries need to be set up.
• You need an employee with good test automation skills.
• Keywords can be a hassle to maintain when scaling a test operation. You will need to
continue building out the repositories and keyword tables.
Improved Readability and Accessibility: The use of keywords makes the test cases
easily understandable by non-technical stakeholders, promoting better collaboration.
Increased Reusability: By modularizing test cases and reusing keywords across
different tests, a hybrid framework can significantly reduce the effort required to write
and maintain tests.
Enhanced Flexibility: Testers can choose the most appropriate testing strategy for each
aspect of the application, whether it's using data-driven techniques for regression tests or
BDD for new features.
Scalability: Hybrid frameworks can scale more effectively with the complexity of the
application, as they can handle both simple and complex test scenarios efficiently.