I will personally not write unit tests for situations where:
The code
has no branchesis trivial. A getter that returns 0 doesn't need to be tested, and changes will be covered by tests for its consumers.The code simply passes through into a stable API. I'll assume that the standard library works properly.
The code needs to interact with other deployed systems; then an integration test is called for.
If the test of success/fail is something that is so difficult to quantify as to not be reliably measurable, such as stenographysteganography being not noticeableunnoticeable to humans.
If the test itself is an order of magnitude more difficult to write than the code.
If the code is throw-away or placeholder code. If there's any doubt, test.