2
solex
11h

Test should be independent and isolated from each other so that they can be run in any order and still produce same result.

I thought we all know this. I was solving an online test were am to validate name,email, ID e.t.c with some constraints given on each field without using a validation library.

some unit tests were written which I can clearly see but can't modify(made sense) but if I choose to validate email it's unit test will not pass until I validate name, and this happens as long as you dont follow the order, this doesn't make sense.

my conclusion, it's either this is intentional or someone has done a bad job. I think this is a bad job since there is no instruction that gives any clue about this.

what do you think about this ?

Comments
  • 0
    Just make tests validating the whole form. Test for each field is not a realistic scenario. It's not expected as user input, so why test it at all. Test whole form and give descriptive name like test_form_validate_email_missing or smth. If you're in a company where literally every function get tested and all together should work because everything works independently.. I have bad news, it's a waste of time philosophy :p I only validate endpoints and stuff these days, barely internals.
  • 0
    smells like a multiple dispatch problem
Add Comment