记一次曾经项目中遇到的错误

曾经项目中遇到的错误:

java大项目中编写一个简单的网上银行系统,其中有一个转账功能,转账金额不超过50元,手续费在本人账户中扣除0.1%。

在测试的时候,用了这几个情况去测试:

1、转账输入20(默认单位都是元)

2、输入—30

3、输入0

4、输入30.56

5、输入字母ab

6、输入600(账户余额是300)

7、输入70

 

在数据库中查看账户金额变化,根据执行结果与预期的比较,测试结果如下:

1正确;2、3、6、7都是预期结果不合理;4、5导致了系统崩溃

 

分析原因:

1、对于2、3、7这三种错误情况,首先对于数字输入的范围没有控制,应该判断输入的金额数值范围在大于0和不超过50,如果不在范围内则跳出提示;

 2、 对于6这种情况,在后台修改数据库中金额之前,先预算一下看是不是余额不足,如果余额足够,在修改数据库,如果余额不足则跳出提示不执行操作;

3、对于4情况,可能是数据库类型定义整数,或者前后台传值部分定义的整数,所以带小数的无法处理。

4、对于5这种情况,应该提示不符合格式,应该在前端用js控制输入,或者后台增加异常处理。

 

错误造成的影响:

2、3、6、7得到了不合理的结果,比如转账是负数,以及余额变成负数、转账金额是0之类的不合理的结果。4、5则因为异常直接导致了系统的崩溃。

 

怎么去检测错误处:

1、根据功能需要设计几个不重复的不同种类的测试案例;2、判断测试案例执行结果是否符合预期;如果不符合,分析原因;3、找可能错误的地方,设断点;4、设置函数向控制台传数据,判断相应的可疑语句是否以及是否正确地修改了数据库;5、结合网页提示的错误;6、修改程序,再次重复以上步骤知道测试案例都符合预期。

 

解决建议:

可以后台增加异常处理,但是在前台判断更好,前台用js判断输入格式,好处一个是数据不用传到后台就可以判断提高了速度,二是减少了后台代码复杂度,三是可以更好的提示,页面美观使用感受更好,更有软件友好度

 

结合这次经历与软件测试的体会:

测试案例的设计要设计不同情况,同一种的可以不重复。软件测试很有必要,否则容易出现异常崩溃但是作者还不知道。软件测试中掌握一定得方式和方法会提高有效性和效率。在软件测试方面我们缺乏专业性的知识,目前还是主要靠经验。我们还需要学习专业的软件测试方法。

 

the error ever encountered in a project :

Java in the big project. Write a simple system of the bank on the net, one of the transfer function, not to transfer more than $50, deduct the 0.1% handling charge in my account.

 

At the time of test, in the few cases to test: 

1, input 20 RMB (the default units are)

2, input - 30

3, 0

4, enter 30.56

5, input letters ab

6, 600 (account balance is just 300)

7, enter 70 

 

Changes in the database to check the account amount, according to the results compared with the expected, the test results are as follows:

1 correct; 2, 3, 6, 7 are expected results are unreasonable; 4, 5, led to a system crash

 

Analysis of reasons:

1, for 2, 3, 7 of these three error conditions, first for the scope of the digital input without control, should determine the amount of input numerical range in greater than zero and no more than 50, if not far out of the tip;

2, for 6 in this case, change the database in the background of the amount before the budget first see if balance is not enough, if the balance is enough, change the database, if insufficient, jump out of the tip is not executed operation;

3, for 4 cases, may be database type's definition, an integer or Taiwan before and after partial definitions of integer, so can't handle with the decimal.

4, for 5 this kind of situation, should prompt does not conform to the format, should be on the front end with js control input, add exception handling or the background.

 

The effects of error:

2, 3, 6, 7, unreasonable results are obtained, such as the transfer is negative, and become a negative balance, transfer amount is 0, such as unreasonable results. 4, 5, because the exception directly lead to the collapse of the system.

 

How to detect errors:

1, according to need to design a few don't repeat function of different types of test cases; 2, to determine whether a test case execution results in line with expectations; If does not conform to, analyze the causes; 3, may find the wrong place, set breakpoints. 4, set the function to the console data, determine whether the corresponding suspicious statements, and whether it is right to modify the database; 5, in combination with web page prompt error; 6, modify the program, repeat the above steps again know that test cases are in line with expectations.

 

Advice of settlement:

Can add exception handling to the background but better judgment at the front desk, reception desk with js judgment input format, benefit is a data can judge without the background to improve the speed, the second is to reduce the background code complexity, three is can better prompt, page is beautiful feeling better, more software friendly.

 

Combined with the experience and software test experience:

Test case design to design different conditions, the same can not repeat. Software testing is necessary, otherwise easy to abnormal collapse but the author is not known yet. To master a certain way and method in software testing will improve the effectiveness and efficiency. We are short of professional knowledge in software testing, is now mainly depend on experience. We also need to learn the professional software testing methods.

原文地址:https://www.cnblogs.com/shangcong/p/5247227.html