App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide Test Case Vs Test Script

Test Case Vs Test Script

By Sharanya R.C., Community Contributor -

In the Software Testing Lifecycle, the two essential components are writing Test Cases and Test Scripts. It will not be surprising if a tester starts mentally writing test cases and scripts for every application that they come across. This guide explains in detail the difference between a Test Case and a Test Script with detailed examples.

What is a Test Case

A Test Case is a document that contains the sequence of actions that validate if the application is working as per the business requirements. Test cases cover all software product features, from clicking a button and accepting input in a text box to checking for storage and a seamless user interface. A complete test case document has to include every possible combination of data and functionalities to be tested on an application before the final product is ready for roll-out.

Test cases give a clear picture of the business requirements of the application. Test case documenting is essential so the testers can recall the feature tested after a long gap. It helps in achieving uninterrupted software testing.

Test Case Prioritization is a vital step in writing test cases. Running all the test cases in a test suite requires a lot of time and effort. As the number of features increases, testing the entire suite for every build is practically impossible. Test case prioritization helps overcome these challenges. 

Example of a Test Case

Let us understand how to write test cases with an example. 

Let’s look at how to write a test case for an e-commerce website. Here the user is logged in and has checked out the items in the shopping cart. The test case is to check the four text boxes where the user inputs the Debit/Credit card number. The payment screen is where the user has to enter the Debit/Credit card details.

Example of a test case

The above example is a Formal Test Case. Here, the document clearly instructs the tester to test specific functionalities with a set of prerequisites and test data. However, there are certain cases where a well-experienced tester tries out different test cases absent in the test case document. Through the tester’s experience, they might test a few random cases and try out various possible inputs to find bugs in the application. These types of cases are called Informal Test Cases. Informal test cases are written when the exact input and output are not known. In such times, the actions are performed, and the outcomes are recorded.

Best Practices to Follow While Writing Test Cases

  1. Keep things simple and clear.
  2. Define the preconditions clearly to avoid confusion.
  3. The test cases are considered effective if they can be reused.
  4. Test case IDs should be unique.
  5. Always think from the end user’s perspective when you begin to write the test case.
  6. Specify the expected results and post conditions.
  7. Make sure you are not repeating test cases. It can easily happen in the urge to cover all the bases.
  8. Refrain from cramming too much information in one test case. Split the test cases to avoid confusion.

Test Script

Test Scripts are step-by-step instructions on how to test a test case. They are detailed and contain individual steps that test for each and every functionality. Test scripts are programs that execute tests on the software product/application. The tester has to write and run the test scripts to validate if the application’s outcome meets the business requirements. 

Test cases serve as a backbone for writing test scripts. A single test case can have multiple test scripts for different testing environments. While most test scripts identify with Automation testing, they can also be a part of manual testing. The testers write automated scripts that can generate data to test every functionality. Usually, the test scripts run automatically and check every test case with various possible input data. Python, Ruby, Perl, Java, VB Script etc are a few of the scripting languages used to write test scripts.

Once written, a test script can execute many test instances that test a single application function. Since the test scripts are more detailed and extensive than test cases, writing test scripts in a reusable format is an excellent practice to make the tester’s life easier.

Example of a Test Script

Let us take the same example as above. 

We have an e-commerce application where the user is logged in and has checked out the items in the shopping cart. He is now on the payment screen, where he has to enter his debit/credit card details. The script can be in any language of the tester’s choice by following the below steps. 

Identify the text boxes or buttons or any element on the screen by its ID (For example, CSS element ID).

For Test Case TC001:

  1. Place the cursor on the first text box.
  2. Type the first four digits.
  3. Type the next four digits. The digits should automatically appear in the following text box. If this happens, the test status is ‘Pass’; if not, the test status is ‘Fail’.
  4. The text boxes should accept all 16 digits split into four text boxes.
  5. Check if there are four digits in the four text boxes. If yes, the test status is ‘Pass’; if not, the test status is ‘Fail’.
  6. Check if the 16-digit input is of number data type. If yes, the test status is ‘Pass’; if not, the test status is ‘Fail’.

For the above script, the test data can be numbers, alphabets, special characters and a combination of all three. It ensures that the text box accepts only numbers and not any other data type.

This script can be coded in any scripting language with test data and executed to test the application for these functionalities.

Best Practices to Follow while Writing Test scripts:

  1. Test scripts cover a wide range of data. So, make sure that the scripts are reusable.
  2. Test scripts should be updated with each change in requirements.
  3. Follow proper naming conventions to ensure proper code maintenance. Make sure the names align with the application and the tested functionality. 
  4. The input of one test script should not depend on the output of another script so that multiple tests can run simultaneously.

Test Cases vs Test Scripts

Test Case

Test Script

A test case is a high-level document with instructions on the specific functionality of the software product to be tested.Test Script is a step-by-step instruction to test each software product’s functionality (test case).
A test case is the software development life cycle’s ‘What to test’ component.Test script is the software development life cycle’s ‘How to test’ component.
Test cases are written in simple English.Test scripts are written in programming languages like VB Script, Python, Java, etc.
A test case is a document with instructions on testing the specific functionality of an application.Test Script is a program that runs various test data on the functionality of an application.
Test scenarios serve as an outline for writing test cases.Test Case serves as an outline for writing test scripts.

 

Test cases are primarily used in Manual Testing.Test scripts are widely used in Automation Testing.
It ensures end-to-end test coverage with assumed data types.It can serve as a reusable component. A single script can run tests with various types of data.
Test cases take a lot of time and resources to document.The time to execute Test scripts is less than the time to write test cases.

Though the primary differences between test cases and test scripts have been established, in some instances, these terms are used in tandem or interchangeably. It is unique to the application being tested, and the practices followed within the project team.

However, the idea behind writing test cases and test scripts remains the same for any type of testing like Functional Testing, Unit testing, Regression testing, and Visual testing, to name a few. With the advent of developing applications to suit a variety of devices, there is immense pressure to test as many test cases as possible without missing out on any functionality or input. 

BrowserStack allows you to seamlessly run your tests on real devices. You can perform manual and automation tests on different browsers and devices. You can run Selenium, Cypress, Playwright,  Puppeteer, Appium, Espresso, and XCUITest tests on a combination of 3000+ browsers, devices, and operating systems.

Try BrowserStack now!

Tags
Automation Testing Manual Testing

Featured Articles

Test Case Reduction and Techniques to Follow

How to run your first Selenium test script

Curated for all your Testing Needs

Actionable Insights, Tips, & Tutorials delivered in your Inbox
By subscribing , you agree to our Privacy Policy.
thank you illustration

Thank you for Subscribing!

Expect a curated list of guides shortly.