Unit Test path C #-use nunit to test which content is right-bicep

Source: Internet
Author: User
ArticleDirectory
    • 1. Right -- is the result correct?
    • 2. B -- are all boundary conditions correct?
    • 3. I -- can I check the reverse Association?
    • 4. c -- can I use other methods to cross-check the results?
    • 5. e -- can you force the occurrence of error conditions?
    • 5. Does P meet performance requirements?
1. Right -- is the result correct?

For testing, the first and most obvious task is to check whether the expected result is correct-the verification result.

For many tests with a large amount of test data, consider using an independent data to store the test data, and then let the unit test read the file. But pay more attention to the test data. Whether in the file orCodeThe test data in may be incorrect. In fact, experience tells us that testing data is more likely to be wrong than code, especially for manual computing or testing data from the calculation results of the original system. Therefore, when an error occurs in the test data, you should check the test data twice or three times on the suspect code frontline.

2. B -- are all boundary conditions correct?

Search for the help phrase correct of the Boundary Condition

Conformance (consistency) -- whether the value is consistent with expectation

Ordering (sequence) -- whether the value is ordered or unordered as it should. Range -- whether the value is within the reasonable minimum and maximum values

Reference (dependency) -- whether the code references external resources that are not beyond the control of the Code itself.

Existence (existence) -- whether a value exists (for example, whether it is non-null, not 0, In a set, etc ).

Cardinality (base) -- Is there enough?

Time (relative or absolute time) -- is everything happening orderly? Is it at the right time? Timely?

3. I -- can I check the reverse Association?

For example, you can square the result to check a function that calculates the square root of the result, and then test whether the result is very close to the original data.

4. c -- can I use other methods to cross-check the results?

Generally, more than one type of data is calculated.Algorithm. We may choose algorithms based on operational efficiency or other features. That is what we want to use in the product; but in the testing system, we can use one of the remaining algorithms to perform cross-test results.

Another method is to use the data of different departments of the class and make sure they can be "combined ". For example, in the library's data system, the amount of lending plus the number of stocks lying on the shelf should always be equal to the total amount of inventory. These are the two separate departments (lending and inventory) of data. They can even be reported by different types of objects, but they must still follow the above constraints (the total number is constant ).

5. e -- can you force the occurrence of error conditions?

An invalid parameter is a piece of cake, but some special technologies are required to simulate network errors without pulling the network cable. Using the mock object can solve such problems.

The following are common environmental factors:

    • Memory consumption
    • Disk Full
    • Clock Problems
    • Network unavailable or faulty
    • System overload
    • Restricted color palette
    • The display resolution is too high or too low.
5. Does P meet performance requirements?

A good part of the check is the performance characteristics, rather than the performance itself. Then, the performance is similar to the trend of "the problem gradually becomes complicated as the input size grows.

What we want is a fast regression test with performance characteristics. Most of the time, the first version we released may work normally, but the second version does not know why it has become slow. We don't know why, what we have changed, or when we dare, almost everything is unknown.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.