3- Test case (CASE)


1. The basic elements of the test case (4) - test environment, operation steps, test data, expected results

(Essential elements of a test case do not require execution results)

Test case (Test Case) is a set of collections provided to the system under test in order to implement the test .

This set includes: test environment, operation steps, test data, expected results (title, serial number, importance, priority, operation method) and other elements.

eg: just like the use cases in the online oj

  • Test environment: LeetCode provides us with a test environment: such as Windows system + Chrome browser.
  • Test data: Niuke.com can input test data by itself, and the background also provides test data.
  • Operation steps: Write the code and click Submit.
  • Expected result: click submit, the pass rate is 100%. If the expected result is the same as the actual result, the test case passes, otherwise it fails.

Test cases solve two major problems: what to test and how to test.

A good test case is that a person who is not familiar with the business can quickly test according to the use case.

Criteria for evaluating test cases:

  • Use cases are clearly expressed without ambiguity.
  • The use case is highly operable.
  • The input and output of the use case are clear.
  • A use case has only one expected result.
  • The maintainability of use cases is good.
  • Use cases have high coverage of requirements.

2. The benefits of test cases

How many test cases to write for a project is uncertain, depending on the difficulty and requirements of the project.

However, the design of test cases is a time-consuming and laborious work, and it often takes more time to design test cases than to execute them. Then why write? reason:

  1. Test cases are the basis for the test executor.
  2. Test cases evaluate requirement coverage.
  3. Test cases can improve the work efficiency of testers/reduce the repetitive problems of testers' work. Reusability, reference significance.
  4. Test cases are the basis for building automated tests. [Automation is to free the hands of testers and let the code execute the test instead of humans]

3. Design method of test cases (based on black box testing)

3.1. Design test cases based on requirements

Designing test cases based on requirements is the basis of test design and development of test cases. The first step is to analyze the test requirements and verify whether the requirements are correct, complete, unambiguous, and logically self-consistent. On the basis of correct requirements, refine the test requirements, extract each test point or test item from the test requirements, and then design the test case according to each test point.

When analyzing test requirements, it is generally divided into functional test requirements and non-functional test requirements.

3.1.2. Functional requirements test analysis

For functional testing, functional block diagrams can be used to help test requirements analysis. To sum up, functional testing requirements usually include the following aspects.

  1. Verification of each functional interface of the system.
  2. Use the business to string together functions for testing.
  3. Functional consistency, interactive (multifunctional interactive operation) test.
  4. Different input of the system, business data test of result output.
  5. The wrong operation of the function, the test of the abnormal operation (belonging to the negative test).
  6. Algorithm verification used in function implementation sometimes requires code review.
  7. The ease of use of user operations and user experience are often verified simultaneously with functional testing.

For specific requirements, the functions of the system can be decomposed into several functional modules according to business classification, user role or user operation area, and then test requirements analysis is performed according to the functional modules. According to the functional module division, business module division is the most common practice.

Example 1: The following analyzes the requirements of a simple calendar system

The functional block diagram of the calendar analyzed according to the functional layout of the web interface is as follows:

It is also possible to use a mind map, which is more convenient and effective, and only presents the analysis results of the test requirements, which can better support the coherence of the test analysis ideas.

Example 2: The following takes the Baidu cloud disk mobile terminal as an example to analyze the function

When conducting demand analysis, business rules such as: Is there any limit to the size of uploaded files; how many files to upload at one time, such as less than 100; how many layers a folder has at most, and so on.

Example 3:

3.1.3. Non-functional requirements testing analysis

Non-functional requirements testing mainly involves performance, security, reliability, compatibility, ease of maintenance and portability, etc. From the perspective of test requirements analysis, each type of non-functional characteristic test needs to be analyzed separately according to the requirements. There may be mutual influence between them, for example, the higher the security, the more likely it will bring greater challenges to usability and performance.

What I want to explain here is that for each application software system, the quality requirements of non-functional characteristics exist, but different project types have different requirements for each non-functional characteristic. This needs to be based on specific projects, specific needs and The characteristics of different product applications are analyzed.

  1. Pure client software, such as word processing software (Word, PPT), media (audio/video) playback software (built-in computer), etc. This type of software has the lowest requirements for system functional testing, but has certain requirements for compatibility, stability and portability.
  2. Client/server (C/S) application system within the enterprise. For example, e-mail, instant messaging systems (Fei Q, Enterprise QQ), etc., are more complex than pure client in terms of system function testing requirements, requiring correct functions and good stability. But on the whole, the requirements for performance, security, and compatibility are not high.
  3. External large-scale and complex network application systems, such as e-commerce, online banking, video sites (Tencent, Youku), etc., in addition to the functional testing requirements of complex systems, the performance, security, compatibility, fault tolerance, and reliability of the system etc. have high demands.

In addition, for large-scale enterprise-level application systems, due to different application modes and system architectures (distributed, microservices, etc.), we must combine architecture and application modes to specifically analyze non-functional test requirements, especially scalability, reliability , security, etc. Technical architecture has little impact on functions, but non-functional testing requires in-depth architectural analysis in order to better understand the scope and method of testing.

example:

How to simulate network?

With the help of tools:

  • Charles (used more in the company)
  • Fiddler

3.2. Specific design method

① Equivalence class

According to the requirements, the input (the output will be considered in special cases) is divided into several equivalence classes, and a test case is selected from the equivalence class. If this test case passes the test, it is considered that the represented equivalence class test is passed. In this way It can achieve as much functional coverage as possible with fewer test cases, which solves the problem that exhaustive testing cannot be performed.

Equivalence class classification:

  • Effective equivalence class: The set of inputs that satisfy the user's needs.
  • Invalid Equivalence Class: An input set that does not satisfy the user's needs.

The equivalence class only considers the classification of the input domain, and does not consider the combination of the input domain, which requires other design methods and supplements.

Steps to design test cases with equivalence class thinking:

  1. Fully understand the requirements.
  2. Divide valid equivalence classes and divide invalid equivalence classes.
  3. Extract a data from the effective equivalence class to design a test case, and extract a data from an invalid equivalence class to design a test case.

example:

② Boundary value

Boundary value analysis is a black box testing method for testing the boundary value of input or output. Usually the boundary value analysis method is used as a supplement to the equivalence class partition method. In this case, the test cases come from the boundary of the equivalence class.

  • 6 < username.length < 15
  • 7 <= username.length <= 14

(both are equivalent)

Boundary point division:

  1. Upper point: A point on the boundary.
  2. Inner point: A point within the boundary (any one of them).
  3. From point: a point near the boundary value (the point closest to the upper point outside the closed interval, and the closest point to the upper point in the open interval).

Example 1: [6, 15]

  • Top score: 6, 15
  • Inner point: 12 (7~14 are acceptable)
  • Off point: 5, 16

Example 2: (6, 15]

  • Top score: 6, 15
  • Inner point: 12 (6~14 are all available)
  • Off point: 7, 16

Steps for boundary value design test cases:

  1. Fully understand the requirements.
  2. Find the boundary point.
  3. Design test cases for boundary points.

 example:

③Decision table method (cause and effect diagram)

Decision tables are another tool for expressing logical judgments.

relation:

  • and:
  • or:
  • Identity:
  • No:

④ Orthogonal arrangement

⑤Scene Design Method

⑥ wrong guessing method

Guess you like

Origin blog.csdn.net/WWXDwrn/article/details/131605054