Write unit tests that test for failure? -


Assuming I have a function that accepts usernames and passwords, it receives records from a database

  • The user is disabled
  • A parameter is compared
  • >

    If If any of these situations is true then the exception is thrown.

    Obviously I want to write my unit test to test my logic, though if an exception is put in and my test will fail, which is not correct - is that so?

  • Yes, your test will throw an exception in the right way, but most (all?) Test frames You can specify the expected exception and pass the exam.

    Be aware of cases where exceptions can be thrown, but those of you Expect other reasons for them


    Comments