1

I am using django python framework for building web application. I am new to testing and i have lot of doubts. Consider my statements below and please let me know whether am i right or not? Consider i am reading a input called frequency in three ways

  1. Read it from user through the website input field. Here i have to test the condition that frequency is invalid other than integer. Here is a chance of alter the field.

  2. If it is read from a file, i also have to test invalid condition since there is a chance to alter the data in the file.

  3. At last consider it read from a database ( data inserted from an other function, and it ensure the inserted data is integer). Here, should i check for the invalid condition? Is there any chance to alter the data in the table due to any attack or virus? Am i required test the invalid condition?

Edit : It is to mention that i am doing unit testing. Now i am testing functions which are not checked for any standard and guidelines for coding. So its my duty to do all checks.

consider two functions, function1 will read devicename & parameter from user through website and insert the data into device table (devicename, parameter & status), status is calculated by comparing the parameter value. status can be red, yellow or green. i am using mysql and all fields are varchar type. parameter should be an integer and hence i ensure it in func1 before inserting it to table.

The function2 just read the device table and display the devicename, parameter & status on another web page.

checklist for testing of func1 is

  1. checked whether the data entered and inserted are correct.
  2. Check whether the invalid param is not inserted to database.
  3. Check all branch conditions in calculating status
  4. check the response status

Checklist for func2

  1. check whether the data read and displayed on web page are correct.
  2. check the response status
  3. check whether the invalid parameter is not shown on web page. This condition will fail because func2 is not capable of handling invalid parameter since it is ensured in func1.
  4. check whether the invalid status is not shown on web page. This will also fail because func2 is not capable of handling the status other than red,yellow and green since status inserted by func1 and func1 is ensuring that status will be in valid range.

But doubt is that for func2, am i need to perform the checklists 3 & 4. Is it required test such a condition?

1 Answer 1

2

It really has nothing to do with whether someone could alter the input file or not; it's a matter of what the code is documented/expected to do, and expected to deal with. You also need to know what level of testing you're doing. Are you testing the individual pieces (unit/function testing), or testing the end-to-end functionality (integration testing)?

So, assuming you're testing the individual pieces: at the UI level, you need to make sure that the input dates within whatever range of values as it's supposed to be in, and whatever format it's in. And you need to make sure that, whenever the data is saved, the data that is saved is the same as what was input.

The same is true when reading the data from a file; the code should make sure that the data is in the format it expects, and within the range of values it expects.

For the database/insert functionality, again, you should make sure that it rejects data in an invalid format, and only accepts valid ranges. Depending on the database technology being used, the database itself may reject invalid data. But it's not your job (usually) to validate the data in the database is correct, but you may need to validate that if the data in the database were wrong, the other layers of the code would behave properly, whatever that's documented to be.

1
  • Sir, pardon me, i didn't get that. I have explained my problem in edits. Please see will you please explain it with an example.?
    – vishnu m c
    Commented Oct 25, 2017 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.