A test case is the backbone of any testing project.
The key to effective software testing is not just how you write test cases, but what scenarios you choose to cover. Once the right test cases are created, they should be closely aligned with the overall test design and test execution strategy to ensure comprehensive and efficient testing.
Let’s explore how to write test cases in the most strategic fashion.
A test case is a specific set of conditions or variables under which a tester determines whether a system, software application, or one of its features is working as intended.
Here’s an example. You are testing the Login pop-up of Etsy, one of the leading E-commerce platforms currently. You’ll need several test cases to check if all features of this page are working smoothly.
Brainstorming time: what features do you want to test for this Login pop-up?
Let’s list down some of them:
That’s just a quick and immediate list. As a matter of fact, the more complex a system is, the more test cases are needed.
Learn More: 100+ Test Cases For The Login Page That You Will Need
A test case usually includes:
Here is an example of a login test case for the Etsy login popup:
Component |
Details |
Test Case ID |
TC001 |
Description |
Verify Login with Valid Credentials |
Preconditions |
User is on the Etsy login popup |
Test Steps |
1. Enter a valid email address. 2. Enter the corresponding valid password. 3. Click the "Sign In" button. |
Test Data |
Email: validuser@example.com Password: validpassword123 |
Expected Result |
Users should be successfully logged in and redirected to the homepage or the previously intended page. |
Actual Result |
(To be filled in after execution) |
Postconditions |
User is logged in and the session is active |
Pass/Fail Criteria |
Pass: Test passes if the user is logged in and redirected correctly. Fail: Test fails if an error message is displayed or the user is not logged in. |
Comments |
Ensure the test environment has network access and the server is operational. |
Make sure to follow the following practices when writing your test cases:
Component |
Best Practices |
Test Case ID |
1. Use a consistent naming convention. 2. Ensure IDs are unique. 3. Use a prefix indicating the module/feature. 4. Keep it short but descriptive. 5. Maintain a central repository for all test case IDs. |
Description |
1. Be concise and clear. 2. Clearly state the purpose of the test. 3. Make it understandable for anyone reading the test case. 4. Include the expected behavior or outcome. 5. Avoid technical jargon and ambiguity. |
Preconditions |
1. Clearly specify setup requirements. 2. Ensure all necessary conditions are met. 3. Include relevant system or environment states. 4. Detail any specific user roles or configurations needed. 5. Verify preconditions before test execution. |
Test Steps |
1. Number each step sequentially. 2. Write steps clearly and simply. 3. Use consistent terminology and actions. 4. Ensure steps are reproducible. 5. Avoid combining multiple actions into one step. |
Test Data |
1. Use realistic and valid data. 2. Clearly specify each piece of test data. 3. Avoid hardcoding sensitive information. 4. Utilize data-driven testing for scalability. 5. Store test data separately from test scripts. |
Expected Result |
1. Be specific and clear about the outcome. 2. Include UI changes, redirects, and messages. 3. Align with the acceptance criteria. 4. Cover all aspects of the functionality being tested. 5. Make results measurable and observable. |
Actual Result |
1. Document the actual outcome during execution. 2. Provide detailed information on discrepancies. 3. Include screenshots or logs if applicable. 4. Use consistent format for recording results. 5. Verify results against the expected outcomes. |
Postconditions |
1. Specify the expected system state post-test. 2. Include any necessary cleanup steps. 3. Ensure the system is stable for subsequent tests. 4. Verify that changes made during the test are reverted if needed. 5. Document any residual effects on the environment. |
Pass/Fail Criteria |
1. Clearly define pass/fail conditions. 2. Use measurable and observable outcomes. 3. Ensure criteria are objective. 4. Include specific error messages or behaviors for fails. 5. Align criteria with expected results and requirements. |
Comments |
1. Include additional helpful information. 2. Note assumptions, dependencies, or constraints. 3. Provide troubleshooting tips. 4. Record any deviations from the standard process. 5. Mention any special instructions for executing the test. |
Here are some more tips for you:
Writing manual test cases is primarily about noting down the test steps.
When it comes to automation testing, the process becomes more complicated.
If you choose manual testing, you only have to execute them following the exact steps as planned. If you go with automation testing, first you need to choose whether you’ll go with a framework or a testing tool.
Simply put:
Install Selenium if you haven’t already:
pip install selenium
The steps we will code include:
Here’s your script:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
# Set up Chrome options
chrome_options = Options()
chrome_options.add_argument("--headless") # Run in headless mode if you don’t need a UI
# Initialize the WebDriver
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
try:
# Navigate to Etsy login page
driver.get("https://www.etsy.com/signin")
# Find the email and password fields and the login button
email_field = driver.find_element(By.ID, "join_neu_email_field")
password_field = driver.find_element(By.ID, "join_neu_password_field")
login_button = driver.find_element(By.XPATH, "//button[@type='submit']")
# Enter credentials (Replace with valid credentials)
email_field.send_keys("your-email@example.com")
password_field.send_keys("your-password")
# Click the login button
login_button.click()
# Add assertions or further actions as needed
# For example, check if login was successful
# WebElement account_menu = driver.find_element(By.ID, "account-menu-id")
# assert account_menu.is_displayed(), “Login failed”
finally:
# Close the browser
driver.quit()
Let’s see how you can do the same thing with Katalon, minus the coding part.
First, you can download Katalon Studio here.
Next, launch it, and go to File > New > Project to create your first test project.
Now create your first test case. Let’s call it a “Web Test Case”.
You now have a productive IDE to write automated test cases. You have 3 modes to choose from
Here's how it works:
You have a lot of environments to choose from. The cool thing is that you can execute any types of test cases across browsers and OS, and even reuse test artifacts across AUTs. This saves so much time and effort in test creation, allowing you to focus on high value strategic tasks.
Test Case:
Test Scenario:
Writing test cases in Agile involves adapting to the iterative and incremental nature of the methodology. Here are some best practices:
There are several types of test cases, each serving a different purpose in the testing process: