A test script is a set of instructions that is used to test the system under test. Test script is a few lines of code written in some programming language. The system under test is checked if it delivers the expected results. Test script is used in automation testing. Some of the scripting languages are :
Many automation tools generate test scripts without the need to write code. For every test case there is a pre-condition, input data, actions to be taken, verification results, expected results. A test script should be written keeping in mind the sequence of flow of actions. Automation provides a managed way of carrying out testing.
Test case prioritization is important, therefore test cases should be prepared keeping in mind their dependencies. For example in a typical web page we have various components like - login, sign up, book order etc. A noteworthy fact is that the test scripts must be written keeping in mind the test scenarios/test cases. Test scripts are intended for test cases. Let us understand what does a test case mean?
A test case can be thought of as a condition with an expected output. For example a very simple process of online transaction requires a person to register into the system if he is a new user and intends to make any online purchase. If a user is registered with the website then he can make online transactions. So the test cases may be somewhat as follows :
Test Case 1:
REGISTRATION - user fills in his details and clicks the submit button, he should be able to get registered.
Expected result - you are registered successfully.
Test Case 2:
LOGIN - user credentials are authenticated, and the user is able to login to the site. Now here we may have two scenarios - valid input (email and password) or invalid input (email or password).
A test script code is thus written as per the test cases. Below is a sample code for login in selenium.
Public class login_user {
public static void main(String[] args)
{
WebDriver web=new FirefoxDriver();
web.manage().timeouts().implicitlyWait(10,TimeUnit.Seconds);
web.findElement(By.id("email")).sendKeys("Enter user Name");
web.findElement(By.id("password")).sendKeys("Enter your password");
web.findElement(By.id("signin")).click();
web.close();
}
}Similarly, there are various automation tools available which can be used to perform testing of an application. Another example is Sikuli, which is a GUI automation tool which uses Sikuli script that's based on Python.
A collection of test scripts along with test data that has a test execution engine, are together known as Test Harness.
A sort of matrix is often prepared to refer to the requirements for a test case. A sample test case's matrix is given as below :
Inputs :
Product | Mandatory |
---|---|
Component customisation report | yes |
Domain analysis report | yes |
Outputs :
Product | Mandatory |
---|---|
Test case/requirements traceability Matrix | yes |
Test script | yes |
Techniques :
Functional System testing |
---|
Roles :
Role | Responsibility |
---|---|
Project Team | Consult |
Test designer/developer | Produce |
Guidelines to be followed while writing test scripts :
Automation is a great way to test a software system as it offers a great ease for carrying out the testing activities. We have the option of customizing a test script as per a given test scenario. It thus allows a tester to view the system under test from every possible dimension and deliver a quality end product.
Advertisement: