Don’t Depend on internal details in your test

One mistake I see many people make is relying on internal details in their tests. For example, assume that you wrote a stack class and that you use an array to store the data. This should be an internal matter for your class. You should not write a test case that verifies the order of elements in the array. Your functional tests should focus on the public interface of that class such as the Push and Pop methods work in the right way.

Depending on an internal implementation detail as in the previous example will prevent you from changing the internal implementation of the class without changing the tests. This negates the benefit of the functional tests you have. The tests should verify that the public interface behaves correctly while allowing you to change the internal implementation as needed without introducing regressions.