Using Variables | Bondar Academy
Course: AI-based testing with testRigor
Module: Reusability and Optimization
Instructor: Artem Bondar
Lesson Summary
In this lesson, we focus on improving reusability and optimization of our tests by utilizing variables . Variables allow us to store values and reuse them throughout the script, reducing duplication and enhancing maintainability. Key Concepts Defining Variables: To create a variable, use the prompt: save , followed by the value and the variable name. For example, save 17 as dayToSelect . Using Variables: Replace hard-coded values in the script with the variable name. For instance, instead of using 17 multiple times, use dayToSelect . Parameterizing Strings: When incorporating variables into strings, use the syntax ${variableName} to ensure proper formatting. Example Implementation In the date picker test , we initially had the date May 17 hard-coded multiple times. By saving it as dayToSelect , we streamlined the script. Similarly, in the table test scenarios , we replaced hard-coded values for columnID , firstName , and lastName with variables. Best Practices Use camel case for variable names (e.g., firstName ). Ensure variable names are meaningful to enhance code readability. Utilize the More Details feature to view the values used during tests. By implementing these practices, we can significantly improve the organization and efficiency of our test scripts. In the next lesson, we will continue to explore further optimizations.