# 4 𝐦𝐢𝐬𝐭𝐚𝐤𝐞𝐬 you are doing while Unit testing that you need to 𝐒𝐓𝐎𝐏 right away:

> [![Mentoring](https://cdn.mentorcruise.com/img/banner/navy-mentoring-badge.svg align="left")](https://mentorcruise.com/mentor/adriankodja/)
> 
> "Unit testing is an essential part of the software development process, and it can help ensure that your code is correct, reliable, and maintainable.”

## Avoid using the anti-patterns mentioned below:

### 𝑼𝒏𝒊𝒕 𝒕𝒆𝒔𝒕𝒊𝒏𝒈 𝒑𝒓𝒊𝒗𝒂𝒕𝒆 𝒎𝒆𝒕𝒉𝒐𝒅𝒔:

Making private methods public just to enable unit testing is a big NO NO, because it couples tests to implementation and, ultimately, makes the tests fragile.

### 𝑬𝒙𝒑𝒐𝒔𝒊𝒏𝒈 𝒑𝒓𝒊𝒗𝒂𝒕𝒆 𝒔𝒕𝒂𝒕𝒆 𝒕𝒐 𝒆𝒏𝒂𝒃𝒍𝒆 𝒖𝒏𝒊𝒕 𝒕𝒆𝒔𝒕𝒊𝒏𝒈:

Don’t expose state that you would otherwise keep private for the sole purpose of unit testing. Your tests should interact with the system under test exactly the same way as the production code; they shouldn’t have any special privileges.

### 𝑶𝒗𝒆𝒓𝒖𝒔𝒊𝒏𝒈 𝒔𝒕𝒖𝒃𝒃𝒊𝒏𝒈:

If you stub everything, you are testing a really small and simple and specific implementation detail. This will make your test fail almost instantly with a refactoring of a name or change in a serialisation method... Your tests will become unclear, brittle and less effective.

### 𝑳𝒆𝒂𝒌𝒊𝒏𝒈 𝒅𝒐𝒎𝒂𝒊𝒏 𝒌𝒏𝒐𝒘𝒍𝒆𝒅𝒈𝒆 𝒕𝒐 𝒕𝒆𝒔𝒕𝒔:

Don’t imply any specific implementation when writing tests. Verify the code from a black-box perspective
