Software Testing - Test Script



The products developed by software teams are constantly evolving, and undergoing changes. These changes are mostly targeted towards the product requirements. As the requirements are updated the test cases are modified as per the requirements. Also, the inputs, and the data fed to the test cases are changed to uncover more defects from the software.

What is a Test Script?

A Test Script is a detailed description on how to verify a test case. It is very exhaustive, and comprises of each step to test individual functionalities of the product. A test script is a program that runs tests on the software. A tester has to design and run a test script to check if the results of running it on the software is as per the user needs.

Test cases designed for a software act as a basis for creation of test scripts. One test case can be converted to many test scripts for various environments. A test script can be executed manually or through automation. Also, test scripts are executed to generate data sets to verify all the software features.

A test script can be implemented using various programming languages like Java, JavaScript, VB Script, and so on. It can be executed against multiple environments to verify the software functionalities with a large combination of data and inputs. A test script is more comprehensive and considerable in nature than a test case, a reusable test script is very useful for testing teams

Why do we Create a Test Script?

A test script is created with the purpose of achieving a good test coverage. It decreases the probability of missing anything during the testing phase and ensuring software quality. It achieves a very detailed and exhaustive test. The creation of test scripts help to achieve a good software quality and performance by being very particular about customer requirements.

Test scripts are very handy in situations when the testing team goes through the software freely and presumes that the function has an expected behavior when it actually does not.

To sum up, a test script conforms that nothing is missed while testing, the customer performance is upto the mark, there is no ambiguous execution, and there is minimum chance of an error.

Techniques to Create a Test Script

The below techniques can be used to create a test script −

Record and Playback

In record and playback, the testers need not write a test script from the beginning. The actions on elements on the webpage are recorded. Those recorded steps are used to create test scripts, and can be later updated, or fixed to streamline automation. A record and playback technique of creating test scripts is very easy, and does not require coding expertise to begin with.

Keyword or Data Driven Test Script

In keyword or data driven test script, has is a clear segregation between testers and developers. The testers use the keywords in a keyword or data driven script without requiring the knowledge of the implementation code.

The implementation, and maintenance of the keywords are the primary responsibilities of the developers. The testers depend completely on the developers to create or update new keywords that help them to test new functionalities.

Programming

The testers have the option to develop a fundamental test script by a record and play back technique. However, test scripts development cannot solely depend on the record and play. The testers need to acquire programming skills in order to create more test scripts.

The programming language chosen for test script preparation is not dependent on the language on which the software is built. For example, Python may be the language on which the software is developed, however, testers may choose Java, or JavaScript for test script preparation.

Best Practices to Create a Test Script

Unambiguous and To The Point

A test script should be unambiguous and to the point to ease the testing process. It should clearly mention the inputs, data, and expected results. It should have only one specific user action.

Reusable

A test script incorporates a wide combination of data, and inputs, therefore should be made in a reusable format.

Designed and Updated as Per Customer Requirements

A test script should be totally as per the customer requirements. At any further changes to the requirements, a test script should be modified accordingly.

Naming Conventions in Code

The code written to create a test script should follow the naming conventions in accordance with the feature and the product being tested for proper code maintenance.

Independent

A test script should not be dependent on the outcome of another test script so that multiple test scripts can be triggered parallelly.

Example of a Test Script

Let us take an example of a flight reservation application, where the user has selected the flight and is about to complete his purchase by entering payment amount. A test script for this scenario is described below −

Step 1 − Identify the payment amount field with the help of any of the locators.

Step 2 − Place the cursor at the payment input field.

Step 3 − Once the amount is entered, the decimal places following the amount should auto populate. For example, if the user enters 1200 INR, the field should display 1200.00 INR. If the application behaves in this way, the test case should be marked as Pass, else Failed.

Step 4 − The amount field should not accept any other thing except positive numbers. For example, if the user enters AAB INR or -1200 INR, he should be restricted from doing so. If the application behaves in this way, the test case should be marked as Pass, else Failed.

Step 5 − The amount field should not accept an amount less or more than his bill amount. For example, if the user has a total bill amount of 12667 INR, he should be allowed to enter only that amount, if he should be restricted from entering anything less or more than. If the application behaves in this way, the test case should be marked as Pass, else Failed.

This test script can have inputs and data ranging from letters, alphabets, numbers, special characters, or a combination of all these. It ensures that the user can only enter a valid, and correct payment amount in the payment field.

Differences Between Test Script and Test Case

A test script contains line by line guidelines to test each and every software functionality with different combinations of data, and inputs, while a test case contains guidelines to test a particular functionality of the software. A test script guides the testers on how to conduct testing, while a test case guides them on what to test.

A test script is created using programming languages like Java, JavaScript, and so on while a test case is developed in simple text. A test script is developed on the basis of a test case, and a test case is developed on the basis of a test scenario. A test script is mainly targeted for automation, and a test case is for manual testing.

A test script requires less resources and time for scripting, but prior scripting a lot of effort goes on research and gathering knowledge on implementation. A test case creation requires a considerable amount of resources and effort.

Conclusion

This concludes our comprehensive take on the tutorial on Software Testing - Test Script. We’ve started with describing what is a test script, why we create a test script, techniques to create a test script, best practices to create a test script, an example of a test script, and what are the differences between test script and test case.

This equips you with in-depth knowledge of Software Testing - Test Script. It is wise to keep practicing what you’ve learned and exploring others relevant to Software Testing to deepen your understanding and expand your horizons.

Advertisements