Automation testing has become an integral part of modern software development, ensuring applications are reliable, efficient, and bug-free. Among the various tools available, Tricentis Tosca stands out with its model-based approach, enabling testers to design robust and maintainable automation scripts without deep programming knowledge. This article aims to guide you through creating and maintaining automation scripts using Tosca, from initial setup to advanced maintenance strategies.
Table of Contents
- Introduction to Tricentis Tosca
- Initial Setup and Project Configuration
- Creating Modules: Building Blocks of Tosca
- Designing Test Cases from Modules
- Data Management and Parameterization
- Executing Tests
- Maintaining Automation Scripts
- Advanced Topics
- Example Workflow
- Conclusion
Introduction to Tricentis Tosca
Tricentis Tosca is a comprehensive test automation tool designed to support continuous testing in Agile and DevOps environments. Unlike traditional scripting-based automation tools, Tosca employs a model-based approach, allowing testers to create reusable modules and test cases that are easy to maintain and scale. This approach not only accelerates test development but also reduces the maintenance overhead associated with frequent application changes.
Why Choose Tosca?
- Model-Based Testing: Enhances reusability and maintainability.
- No Coding Required: Accessible to testers without deep programming skills.
- Comprehensive Support: Covers a wide range of applications, including web, desktop, API, and more.
- Integration Capabilities: Seamlessly integrates with CI/CD pipelines and other tools.
1. Initial Setup and Project Configuration
Key Activities:
Install and Configure Tosca
Before diving into automation, ensure that Tosca Commander, TBox components, and any necessary engines (e.g., TBox Web Engine) are correctly installed on your system. Follow the installation guide provided by Tricentis to set up your environment.
Set Up a Common Repository (Workspace)
A centralized repository ensures that all team members work with the latest test assets. Tosca supports multi-user repositories, typically hosted on a shared database.
- Create Workspaces:
- Open Tosca Commander.
- Navigate to Project > New to create a new project.
- Connect to a central repository via Project > Project Settings > Repository.
Define Folder Structures
Organizing your project logically is crucial for scalability and ease of maintenance.
- Modules: Group by application and specific features or pages.
- Test Cases: Organize by functional areas, such as Login, Shopping Cart, Payment, etc.
- Execution Lists: Categorize by environment (e.g., Development, Staging, Production) or test cycles.
Example Folder Structure:
- Modules
- ApplicationA
- Login
- Dashboard
- TestCases
- LoginTests
- PaymentTests
- ExecutionLists
- DevEnvironment
- ProdEnvironment
2. Creating Modules: Building Blocks of Tosca
Modules in Tosca represent the UI elements or API endpoints of the application under test. They serve as reusable components across multiple test cases.
Key Activities:
Scan the Application to Create Modules
Use Tosca’s XScan feature to identify and model the controls from your application’s user interface.
Steps:
- Open Tosca Commander.
- Right-click on the Modules folder and select Scan Application.
- Choose the appropriate engine (e.g., Web, Desktop, API) based on your application type.
- Highlight the UI controls you wish to automate (e.g., buttons, text fields, dropdowns) and add them to your module.
Parameterize Modules
Assign meaningful names to each control to enhance readability and reusability.
Examples:
- Button [Login]
- Text Field [Username]
- Text Field [Password]
Ensure Reusability
Design modules to be as generic as possible. For instance, a login screen module should include fields like Username, Password, and a Login button, allowing it to be reused across different test cases that require login functionality.
3. Designing Test Cases from Modules
Test cases in Tosca are created by combining modules to simulate user interactions and validate application behavior.
Key Activities:
Drag and Drop Modules into Test Cases
Create test cases by assembling modules in Tosca Commander.
Steps:
- Right-click on the TestCases folder and create a new folder, e.g., “Login Tests”.
- Within this folder, create a new TestCase named “ValidLogin”.
- Drag and drop the previously created Login Module into the TestCase.
- Populate the test steps with appropriate values:
- Username:
testuser
- Password:
testpass
- Button [Login]:
Click
- Username:
Add Verification Steps
Ensure the test case not only performs actions but also verifies expected outcomes.
Example:
- After clicking the Login button, verify the presence of a “Logout” link on the home page to confirm a successful login.
Parameterization Using TestCase Design
For data-driven testing, link test steps to a TestCase Design Sheet to run the same test case with different data sets.
Steps:
- Create a TestCase-Design folder and define attributes like “Username” and “Password”.
- Populate these attributes with multiple test variants (e.g., valid, invalid, blank).
- Link these attributes to the test steps using
= <Attribute Name>
notation.
Example Test Step:
TestStep: Login
-> Username = <USERNAME>
-> Password = <PASSWORD>
-> Button [Login] = Click
4. Data Management and Parameterization
Effective data management is essential for creating flexible and reusable test cases.
Key Activities:
Utilize External Data Sources
Connect Tosca to external data sources like Excel or databases to manage test data efficiently.
Steps:
- Right-click on the TestCase-Design folder.
- Select Import from Excel and choose your spreadsheet containing test data.
Leverage Tosca Buffers
Buffers store dynamic values during test execution, allowing data reuse across multiple test steps.
Example: If an Order ID is generated during a test, you can buffer it for later verification:
TestStep: ConfirmOrder
-> OrderID (Verify) = {B[OrderID]}
Create Reusable Test Steps and Libraries
Develop a Reusable TestSteps folder containing common sequences (e.g., login, logout) that can be incorporated into various test cases, enhancing consistency and reducing duplication.
5. Executing Tests
Executing your test cases is the final step before validating the application’s functionality.
Key Activities:
Set Up Execution Lists
Organize your test cases into ExecutionLists to manage and execute them collectively.
Steps:
- Navigate to the Execution section in Tosca Commander.
- Create a new ExecutionList and drag your desired test cases into it.
Configure Execution Settings
Customize the execution environment based on your requirements.
- Select Browser or Environment: Choose the target browser or system environment for the test run.
- Set Data Sources: For data-driven tests, ensure the correct data sources are linked.
Run Tests from Tosca Commander
Initiate the test execution process directly from Tosca Commander.
Steps:
- Select the ExecutionList you created.
- Click the Run button.
- Monitor the execution progress and review logs in the Execution tab.
Integrate with CI/CD Pipelines (Optional)
For continuous integration and deployment, integrate Tosca test runs into CI/CD tools like Jenkins or Azure DevOps.
Steps:
- Utilize Tosca’s CI features or the Tosca Distributed Execution (DEX) service.
- Create a Tosca CI configuration file.
- Trigger tests via command line within your CI/CD pipeline.
6. Maintaining Automation Scripts
Maintenance is a critical aspect of automation testing, ensuring that your test scripts remain effective as the application evolves.
Key Activities:
Modularization for Maintainability
By designing reusable modules, you can update a single module when the application changes, rather than modifying multiple test cases.
Refactor Modules When Necessary
If an application’s UI elements change (e.g., element IDs or XPath), update the affected modules accordingly.
Steps:
- Open the relevant module in XScan.
- Update the control properties (e.g., new XPath or ID).
- Save the module to propagate changes across all linked test cases.
Adjust Test Data as Needed
Update test data in the TestCase Design Sheets rather than altering individual test cases to accommodate changes in test scenarios or credentials.
Versioning and Branching
Use Tosca’s multi-user workspace with version control to manage different versions of test scripts. Create branches for major updates, test changes in isolation, and merge back into the main branch after validation.
Regular Reviews and Cleanup
Periodically assess your modules, test steps, and test data to eliminate obsolete or redundant elements. Archive or delete outdated ExecutionLists to keep the repository clean and organized.
7. Advanced Topics
Once you’re comfortable with the basics, exploring advanced features can further enhance your automation framework.
Key Activities:
Custom Conversions and Actions
Implement custom controls or actions using Tosca’s TBox Customization when built-in engines don’t meet specific testing needs.
API Testing with Tosca
Extend your testing capabilities to APIs by creating API modules. Import service definitions like WSDLs or OpenAPI specs and parameterize them similarly to UI tests.
TestCase Templates
Develop templates that define common patterns of test steps, allowing you to generate multiple test cases automatically based on different data sets.
8. Example Workflow
To solidify your understanding, let’s walk through an example workflow for automating a login feature using Tosca.
Step-by-Step Example:
- Create a Module:
- Launch XScan on the login page.
- Identify and model the Username and Password fields, and the Login button.
- Save this module as “LoginModule.”
- Create Test Data (Optional):
- Navigate to the TestCase-Design folder.
- Define attributes:
USERNAME
,PASSWORD
. - Populate with test data: USERNAME PASSWORD testuser1 pass1234 testuser2 pass5678
- Create TestCase from Module:
- Create a new TestCase named “TC_ValidLogin.”
- Drag LoginModule into “TC_ValidLogin.”
- Set the test steps:
- Username:
<USERNAME>
- Password:
<PASSWORD>
- Button [Login]:
Click
- Username:
- Link Data:
- Link
USERNAME
andPASSWORD
from the TestCase Design to the TestCase, enabling multiple test variants based on the data.
- Link
- Run Execution:
- Create an ExecutionList and add “TC_ValidLogin” to it.
- Execute the tests and monitor the results.
- Maintain Scripts:
- If the login page changes (e.g., Username field ID changes), update the LoginModule’s locator in XScan.
- All TestCases using LoginModule will automatically reflect the update.
Conclusion
Tricentis Tosca offers a powerful and flexible platform for automation testing through its model-based approach. By focusing on creating reusable modules, managing data efficiently, and organizing test cases systematically, students can develop robust and maintainable automation scripts. As applications continue to evolve, Tosca’s features ensure that your automation framework remains resilient and adaptable, providing reliable testing outcomes in dynamic development environments.