• info@helpingtesters.com
  • helpingtesters

Write Use cases or Test cases?

January 26, 2017
Use cases,test plan, test case, use case, use case example

Use cases and test cases are the terms that are heard very often in Software Testing industry. They both are designed/developed to identify the ways in which the users interact with the system to achieve the expected result in a specific way. Most probably both the documents will contain the same set of data and instructions. And maybe this is why Use Case and Test Case terms are used interchangeably, and this is wrong too. The difference between Use Case and Test Case lies within the scope and purpose of designing them.

Being a software tester it is very much required to understand and interpret the actual meaning of Use Cases and Test Cases and act accordingly. With the rise in testing in mobile software industry the needs to design/develop use cases has risen, as the more use cases we test the more reliable the software is.

Basically to understand at higher-level, what is the use case and test case, consider an online shopping scenario where the user is required to add the particular product to the cart with quantity 3. Use case just says add the product to cart with n quantity. Whereas Test case describes, how to go the particular product page, set the quantity to 3 and then add it to the cart. Here again, test case covers the precondition that product quantity available in the warehouse should be minimum 3, and all the possibilities while adding the product to the cart:

  • Adding the product at once by setting the quantity to 3
  • Adding the same product 3 times with quantity 1
  • Adding the same product 2 times with quantity 1 for the first time and 2 for the second time
  • Adding the same product 2 times with quantity 2 for the first time and 1 for the second time

Understanding the terminologies: Use Case and Test Case

  1. Use Case

By the definition use case is the step by step events developed for the interaction between a role and the system, i.e., to tell how the user interacts with the system. The goal of use case is to advise the development team about the user expectations from the system. Basically, business and user requirements are captured here by describing all the possible paths for the user to interact with the system. Paths here are Basic Path, Alternative Path, and Exceptional Path.

  • Basic Path, also called Happy Path, is the direct flow which captures the user-system interaction directly.
  • Alternative Paths are those flows where user-system interaction happens through different ways which are not so common or desirable. These paths are not frequently used in the system, but cannot be left untested.
  • Exceptional Paths are the flows which fail to achieve user goals with the system due to any reasons: invalid input, missing input, canceling, etc.

It’s very usual that, a single use case can have multiple paths to test and ensure the user-system interaction through all the paths.

Use Cases are one of the inputs to design/develop test cases.

  1. Test Case

By the definition, a test case is a set of conditions or variables under which the response of the system will be tested and evaluated. The purpose of writing test case is to validate whether the system meets all the specified requirements. Test Case is written for each and every path that is described in the use case, which is executed by the testers during the execution phase of the Software Testing Life Cycle. It is preferred to write the separate test cases for every individual path identified for the user-system interaction.

Test Cases are intended for the testers to validate each of them for quality assurance. It is recommended to start writing test cases as early as possible.

Example to understand Use Case and Test Case

In all the applications that support user profile, Reset password flow is one of the basic features to be tested. Here in the example, we will try to understand how the Use Case Diagram and Use Case Scenarios can be written for the feature and the respective test cases to cover the same.

Use Case Diagram

Above Use Case diagram helps to understand the Reset Password feature flows through Email. All the possible flows are shown with arrows which have to be followed the same way to complete the respective flow.

Use Cases / Use Case Scenarios

Now let us analyze the possible Use Case Scenarios that can be derived from Use Case Diagram.

Preconditions:

  • User should have the active account in the application

Scenarios:

  1. User initiates Reset Password flow through Forgot Password button/link
  2. User should be able to request the reset password via Email
  3. Reset password Via Email
    • 3.1   Reset password through the link received in Email within 24 hours
    • 3.2   Click on the reset password link received in Email after 24 hours
      • 3.2.1   New Email should be received with the new reset password link
    • 3.3   Try Reset password through invalid link
      • 3.3.1   Copy-Paste the reset password link in browser and edit the code part of the link before launching
      • 3.3.2   Click on the reset password link received earlier in the Email (2-3 previous Emails)
      • 3.3.3   In both the cases 3.3.1 and 3.3.2, new Email should be received with the new reset password link

The use case diagrams and scenarios are useful in designing how the user should interact with the system. This will be helpful for the developers too for reference while program design. The developers will check and evaluate the use case scenarios when they complete each module of the system. This will ensure they are going in the right way. The use case diagrams are also helpful for the creation of test case scenario.

Test Cases

The Quality Analysts are responsible for creating test criteria. The use case diagrams will also be helpful in creating test cases based on each use case scenarios. The test cases should aim at verifying system’s actual behavior with expected results.

Here we will cover how test cases are written based on the Use Case Diagram and Use Case Scenario:

TC_ID Test Case Name Scenario # Precondition Test Steps Expected Result
1 Forgot Password 1   1.      Launch the application

2.      Click on Forgot Password button

Verify three options are displayed to the user:

1.      Via Email

2.      Via SMS (covered in other sample examples)

3.      Via Call (Covered in other sample examples)

2 Via Email 2   1.      Click on Via Email Verify user is asked to enter the Email address to send reset password link
3 Send Reset Password link to Valid Email Address 3 User’s Email address should be registered and activated in the application 1.      Enter the valid Email address in the text box

2.      Click on Reset Password

Verify user receives an Email with reset password link
4 Non-registered Email Address attempt to reset password 3 Email address should not be registered in the application 1.      Enter the non-registered Email address in the text box

2.      Click on Reset Password button

Verify error message “Email address not registered” is displayed
5 The invalid Email address format 3   1.      Enter Email address in invalid format

2.      Click on Reset Password button

Verify error message “Invalid Email Address” is displayed
6 Email Address field blank 3   1.      Leave the Email address field blank

2.      Click on Reset Password button

Verify error message “Provide the registered Email address” is displayed
7 Reset Password link – Successful 3.1 User should have received Email Address with Reset Password link 1.      Access user’s Email account within 24 hours

2.      Open the Email received for Reset Password via Email

3.      Click on the Reset Password link present in the Email

Verify user is allowed to reset the password
8 Reset Password after 24 hours 3.2 User should have received Email Address with Reset Password link 1.      Access user’s Email account after 24 hours

2.      Open the Email received for Reset Password via Email

3.      Click on the Reset Password link present in the Email

Verify User is not allowed to reset the password and appropriate error message is displayed
9 Reset Password after 24 hours – new Email 3.2.1   1.      Check the Email Address again Verify new Email is received with new Reset Password link
10 Invalid Reset Password link – Copy-Paste method 3.3.1 User should have received Email with Reset Password link 1.      Access user’s Email account

2.      Open the Email received for Reset Password via Email

3.      Copy the Reset Password link present in the Email and Paste it into the browser

4.      Change the code present in the link URL and hit Enter key

Verify User is not allowed to reset the password and appropriate error message is displayed
11 Invalid Reset Password link – Copy-Paste method – new Email 3.3.3   1.      Check the Email Address again Verify new Email is received with new Reset Password link
12 Invalid Reset Password link – Expired link 3.3.2 User should have received Email earlier with Reset Password link 1.      Access user’s Email account

2.      Open the Email received earlier for Reset Password via Email

3.      Click on the Reset Password link present in the Email

Verify User is not allowed to reset the password and appropriate error message is displayed
13 Invalid Reset Password link – Copy-Paste method – new Email 3.3.3   1.      Check the Email Address again Verify new Email is received with new Reset Password link

The flow varies from application to application. Here an attempt is made to understand the Use Case and Test Case terminologies with the simple example.

Try yourself to Reset Password via SMS and via Call. Click the below links to check the sample examples for the same:

Reset Password via SMS

Reset Password via Call

Difference between Use Cases and Test Cases

Use Cases

Test Cases

Use cases are developed  as step by step events which describes how to execute functionality Test cases are developed based on the use cases and verifies the functionalities defined
Use cases are developed based on the Business Requirement Specifications[BRS] Test cases are developed based on the Use Cases
Use cases are prepared by Business Analyst Test cases are prepared by Quality Analysts
Use cases are made based on one or more use case scenario. The Use Case scenario defines how to achieve the business requirement goals. The test cases scenarios will describe “What to be tested”. The test cases designed for the test case scenario specify “How to be Tested”
Use cases are only designed and cannot execute Test cases are developed based on the use cases and are executed later
Use cases document will explain how the user interacts with the software and the business goals The test case documents will verify the goal to see whether all the required test cases are executed or not
Use cases are documented once and verify whether all the requirements are involved or not Test cases documents will be updated after each test phases and will get updated with the test results
Use Cases are pictorial representation of the user-system interaction Test Cases are documented in Excel Sheets or in Test Management Tools
Use Cases can combine relevant multiple scenarios in single document Since Test Cases cannot have combined results, it is not recommended to include multiple scenarios in the same test case document.
Use case documents are used for reference purpose only Test case documents are used for test executions and the results will vary as per the input.
User Acceptance Testing phase depends on Use Case Documents Regression and System Testing phases depends on Test Case Documents
Use Case adds more value to understand and enhance the business flows Test Case adds more value to the QA work during execution phase
Use Case is complimentary testing, and cannot judge the quality of the application Test Case is validation activity which helps in judging the quality of the application
Use Case does not provide entire coverage of the system Test Case goal is to achieve 100% coverage of the system, which is possible through Reverse Traceability Matrix.
Use Case helps in uncovering only Integration defects that comes along the path Test Cases helps in uncovering all the defects throughout the system

Conclusion

The use case and test case are sometimes considered to be the same. The concepts in designing both are same on the technical side. But, the important aspect is that use cases are more specific to the client’s point of view. 

The use case diagram describes the exact requirement of the client and what they expect their system to be. So, there is a chance to identify missing links in use case diagrams. These links will be filled later when the system design goes on. Also, use cases are the means to identify the ambiguous paths, incomplete requirements, hidden logic, missing requirements, etc.

The test case is specific and concise to the actual performance of the system. The quality assurance of the system is ensured by the execution of the most specific test cases. The test case derived from the use case diagrams and they confirm that the use case diagrams denote the actual results which are possible to achieve. Test Cases are the means to assess the system and ensure the quality of the same.

Testers refer use cases to write test case documents, whereas, developers refer use cases to implement all possible integrations within the system. Both, Use Cases and Test Cases, have equal importance in Software Testing Industry, but they have to be used correctly based on the context at any point in time. Even though they both provide the same basic information and overlap, they are not the same as described in this article. Make use of these documents wisely in the project to gain more efficiency and accuracy during the validation phase.

Hello, this is Nandini.

About the author

Nandini KS editor

Hello, this is Nandini.

1 Comment

Gopika

February 11, 2017 at 7:36 am

wow!! The fantastic difference between use case and test cases. Really it will be helpful for the testing beginners and even experienced professionals. Thanks for a great post buddy. The test case tabular column explanation is very clear and easy to understand.

Leave a Reply

Your email address will not be published.