How to write a Test Design
How to Create a Test Case
Let’s create a Test Case for the scenario: Check Login Functionality
Step 1) A simple test case for the scenario would be
Test Case # | Test Case Description |
---|---|
1 | Check response when valid email and password is entered |
Step 2) In order to execute the test case, you would need Test Data. Adding it below
Test Case # | Test Case Description | Test Data |
---|---|---|
1 | Check response when valid email and password is entered | Email: [email protected] Password: lNf9^Oti7^2h |
Identifying test data can be time-consuming and may sometimes require creating test data afresh. The reason it needs to be documented.
Step 3) In order to execute a test case, a tester needs to perform a specific set of actions on the AUT. This is documented as below:
Test Case # | Test Case Description | Test Steps | Test Data |
---|---|---|---|
1 | Check response when valid email and password is entered |
1) Enter Email Address 2) Enter Password 3) Click Sign in |
Email: [email protected] Password: lNf9^Oti7^2h |
Many times the Test Steps are not simple as above, hence they need documentation. Also, the author of the test case may leave the organization or go on a vacation or is sick and off duty or is very busy with other critical tasks. A recently hire may be asked to execute the test case. Documented steps will help him and also facilitate reviews by other stakeholders.
Step 4) The goal of test cases is to check behavior the AUT for an expected result. This needs to be documented as below
Test Case # | Test Case Description | Test Data | Expected Result |
---|---|---|---|
1 | Check response when valid email and password is entered | Email: [email protected] Password: lNf9^Oti7^2h |
Login should be successful |
During test execution time, the tester will check expected results against actual results and assign a pass or fail status
Test Case # | Test Case Description | Test Data | Expected Result | Actual Result | Pass/Fail |
---|---|---|---|---|---|
1 | Check response when valid email and password is entered | Email: [email protected] Password: lNf9^Oti7^2h | Login should be successful | Login was successful | Pass |
Step 5) That apart your test case -may have a field like, Pre - Condition which specifies things that must in place before the test can run. For our test case, a pre-condition would be to have a browser installed to have access to the site under test. A test case may also include Post - Conditions which specifies anything that applies after the test case completes. For our test case, a postcondition would be time & date of login is stored in the database
The format of Standard Test Cases
Below is a format of a standard login Test case
Test Case ID | Test Scenario | Test Steps | Test Data | Expected Results | Actual Results | Pass/Fail |
---|---|---|---|---|---|---|
TU01 | Check Customer Login with valid Data |
|
Userid = guru99 Password = pass99 | User should Login into an application | As Expected | Pass |
TU02 | Check Customer Login with invalid Data |
|
Userid = guru99 Password = glass99 | User should not Login into an application | As Expected | Pass |
This entire table may be created in Word, Excel or any other Test management tool. That's all to Test Case Design
While drafting a test case to include the following information
- The description of what requirement is being tested(描述测试的需求)
- The explanation of how the system will be tested(解释说明系统测试的方法)
- The test setup like a version of an application under test, software, data files, operating system, hardware, security access, physical or logical date, time of day, prerequisites such as other tests and any other setup information pertinent to the requirements being tested(若有需要,将应用程序版本,软件,数据文件,操作系统,硬件,安全访问,物理或逻辑日期,时间,其他测试等先决条件设置为Test Setup)
- Inputs and outputs or actions and expected results(标注输入输出或行为以及预期结果)
- Any proofs or attachments(如有需要标明附件)
- Use active case language(语言标准化?)
- Test Case should not be more than 15 steps(Test Case最好不要超过15步)
- An automated test script is commented with inputs, purpose and expected results(自动测试脚本注释了输入,目的和预期结果)
- The setup offers an alternative to pre-requisite tests(提供可替代的先决条件的测试)
- With other tests, it should be an incorrect business scenario order
Best Practice for writing good Test Case Example.
1. Test Cases 需要简单且透明:
Create test cases that are as simple as possible. They must be clear and concise as the author of the test case may not execute them.
Use assertive language like go to the home page, enter data, click on this and so on. This makes the understanding the test steps easy and tests execution faster.
2.树立最终用户的观点
The ultimate goal of any software project is to create test cases that meet customer requirements and is easy to use and operate. A tester must create test cases keeping in mind the end user perspective
3. 避免重复.
Do not repeat test cases. If a test case is needed for executing some other test case, call the test case by its test case id in the pre-condition column
4. 测试过程不要修改程序的功能和feature
Do not assume functionality and features of your software application while preparing test case. Stick to the Specification Documents.
5. 确保100%覆盖各种情况
Make sure you write test cases to check all software requirements mentioned in the specification document. Use Traceability Matrix to ensure no functions/conditions is left untested.
6. 命名Test Cases时确保含义清晰.
Name the test case id such that they are identified easily while tracking defects or identifying a software requirement at a later stage.
7.相关的Testing Techniques
It's not possible to check every possible condition in your software application. Software Testing techniques help you select a few test cases with the maximum possibility of finding a defect.
- Boundary Value Analysis (BVA): As the name suggests it's the technique that defines the testing of boundaries for a specified range of values.
- 边界值分析:基于在分区之间的边界处进行测试。 它包括最大,最小,内部或外部边界,典型值和误差值。
- 事实证明大量错误发生在定义的输入值的边界而不是中心。
- 此测试用例设计技术补充了等价划分技术。
- Equivalence Partition (EP): This technique partitions the range into equal parts/groups that tend to have the same behavior.
- 等效类分区: 将测试条件集划分为一个应该被视为相同的分区。
- 这种技术背后的概念是每个类的代表值的测试用例等于对同一个类的任何其他值的测试。
- 可用来识别有效和无效的等价类。
- State Transition Technique: This method is used when software behavior changes from one state to another following particular action.
- 在状态转换技术中,输入条件的变化会改变被测应用程序(AUT)的状态。
- 该测试技术允许测试人员测试AUT的行为。 测试人员可以通过按顺序输入各种输入条件来执行此操作。
- 在状态转换技术中,测试团队提供正输入测试值和负输入测试值,用于评估系统行为。
- Error Guessing Technique: This is guessing/anticipating the error that may arise while doing manual testing. This is not a formal method and takes advantages of a tester's experience with the application
- 错误猜测:它基于猜测代码中可能存在的错误。
- 这是一种基于体验的技术,测试分析师使用他/她或经验来猜测测试应用程序中存在问题的部分。
- 该技术计算可能的错误或容易出错的情况列表
8. 测试结束后返回测试前的环境
The test case you create must return the Test Environment to the pre-test state and should not render the test environment unusable. This is especially true for configuration testing.
9. 保证测试独立
The test case should generate the same results every time no matter who tests it
10. 让同事帮忙Review
After creating test cases, get them reviewed by your colleagues. Your peers can uncover defects in your test case design, which you may easily miss.
Test Case Management Tools
Test management tools are the automation tools that help to manage and maintain the Test Cases. Main Features of a test case management tool are
- For documenting Test Cases: With tools, you can expedite Test Case creation with use of templates
- Execute the Test Case and Record the results: Test Case can be executed through the tools and results obtained can be easily recorded.
- Automate the Defect Tracking: Failed tests are automatically linked to the bug tracker, which in turn can be assigned to the developers and can be tracked by email notifications.
- Traceability: Requirements, Test cases, Execution of Test cases are all interlinked through the tools, and each case can be traced to each other to check test coverage.
- Protecting Test Cases: Test cases should be reusable and should be protected from being lost or corrupted due to poor version control. Test Case Management Tools offer features like
- Naming and numbering conventions
- Versioning
- Read-only storage
- Controlled access
- Off-site backup
Popular Test Management tools are: Quality Center and JIRA
Resources
- Please note that the template used will vary from project to project. Read this tutorial to Learn Test Case Template with Explanation of Important Fields