Code smells

Code smells (also known as bad smell when referred to software) are undesirable symptoms within the source code. Code smells are not problematic per se, but they can evidence some kind of issue nearby.

As described in previous sections, tests should be simple and easy to read. With that promises, code smells should be present in our tests under no circumstances. All in all, generic code smells might be avoided in our tests. Some of the most common code smells are the following:

  • Duplicated code: Cloned code is always a bad idea in software, since it breaks the principle Don’t Repeat Yourself (DRY). This problem is even worst in tests, since test logic must be crystal clear.
  • High complexity: Too many branches or loops may be potentially simplified into smaller pieces.
  • Long method: A method that has grown too large is always problematic, and it is a very bad symptom when this method is a test.
  • Unappropriated naming convention: Variables, class, and method names should be concise. It is considered a bad smell to use very long identifiers, but also use excessive short (or meaningless) ones.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.36.146