BernardoBF4's avatar

Example of a case where unit tests pass but not the feature test

I've been reading (and checking some nice gifs) about how you can have unit tests that pass but have a failed integration of what those tests test. The problem is I can't think of an example of how I can have these two things at the same time: failing integration put passing units in my code.

Can you please help me with examples? Code or external sources are ok.

0 likes
4 replies
BernardoBF4's avatar

@cwhite Thanks for the reply. Actually I wanted a code example (I edited my question to specify that).

PovilasKorop's avatar
Level 11

Imagine a few Auth tests.

Unit tests:

  • Test the permission list of a certain user returns correct permissions
  • Test the password is encrypted correctly when user is created

Feature/integration tests:

  • Registration form filled in to get the correct role/permission
  • Profile update password form updates data correctly

So it's about the same data, but internal checks may work correctly, but the features "from outside" may be called incorrectly or depend on each other in a wrong way.

1 like
BernardoBF4's avatar

@PovilasKorop Thanks a lot for your response. It did help me find an example. Plus, your videos are really helpful, I even used one of them about TDD to explain it to my coleagues.

Please or to participate in this conversation.