Talking about Software Testing (Part 1)

    Software testing occupies an important position in the life cycle of software. Now software testing has developed into an industry. In many internationally renowned IT companies, the ratio of software testers to software developers is close to 1:1. At Microsoft The ratio of software testers to software developers is 1.5~2.5:1, so Bill Gates once said that many people think that Microsoft is a software development company. In fact, Microsoft is a software testing company. This shows that software testing has an impact on software quality. The importance of assurance. 

    In order to verify whether a program has completed a predetermined function (to achieve a predetermined effect), we usually test the program. At present, software testing is still an effective means to find software defects and ensure software quality. 

Question: What is the basic method of program testing?

[Note] A set of given input and output data is called a test case. 

[Note] Due to time and cost constraints, it is almost impossible and unrealistic to test all input data. Therefore, we need to select some very representative input data to test the program. 

Question: How to select test cases?

    Test data should cover all branches (paths) of the program as much as possible, and minimize repeated coverage. On this basis, we should not only consider legal input data, but also illegal input data and various boundary conditions. Above Take the program in the figure as an example, the input data {-5,-10,105,110} is illegal input data. We input this group of illegal data into the program, and find that the actual result of the input data {-5,105} is not as expected. Consistent-at this time we found a problem with the program. Since it is impossible for us to test all possible input data, we need to select some representative input data for testing, so the program test is actually Carry out sampling inspections.

Question: What is the purpose of program testing?

 

Question: What are the main tasks of testers?

Question: What are the classifications of program testing methods?

Back to the program at the beginning of this article:

    After fully understanding the internal logic structure of the program, we give the input data shown above, which is a typical white box test method. The input data {-5, 105} is given, which is a typical boundary test method. 

Question: How to modify the program for the current bug?

    You can first judge whether the input score is legal, if it is not, just output "input error"; if it is legal, perform the step of mark=score/10, and then enter the switch() structure for judgment-this can be avoided When the input score is in the interval [-9, -1]∪[101, 109], the output does not meet expectations.

#include<stdio.h>
int main()
{
    int score, mark;
    printf("Please input score:");
    scanf("%d", &score);
    if(score>=0&&score<=100)//确保数据的合法性
    {
        mark=score/10;
        switch(mark)
        {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5: printf("grade:E\n"); break;
            case 6: printf("grade:D\n"); break;
            case 7: printf("grade:C\n"); break;
            case 8: printf("grade:B\n"); break;
            case 9:
            case 10: printf("grade:A\n"); break;
        }
    }
    else
    {
        printf("Input error!\n");
    }
    return 0;
}

[Note] After testing with the test cases shown above, no new bugs have been found. 

 

Guess you like

Origin blog.csdn.net/weixin_42048463/article/details/115078491