Thread
Do you know, Unit tests, just like Production code can be subject to bad programming ?

In today's #Python ๐Ÿ daily we look at Test Smells ๐Ÿ‘ƒ
Before we proceed, a humble request to support by journey free of cost by subscribing to my channel

youtu.be/sNihKT7YScY
๐ŸŸ  Test smells are defined as bad programming practices in unit test code.

๐Ÿ”ต It's not enough to just write tests, it's important to write good tests. Some of the common test smells are
{ Eager Test }

๐ŸŸ  Occurs when a test method invokes several methods of the production object

๐Ÿ”ต This smell results in difficulties in test comprehension and maintenance
{ Magic Number Test }

๐ŸŸ  Occurs when assert stmt in a test contain numeric literals (i.e., magic numbers) as params. Magic nos do not indicate meaning/purpose of the number

๐Ÿ”ต Should be replaced with constants/variables, thereby providing a descriptive name for the input
{ Conditional Test Logic }

๐ŸŸ  Conditions within the test method will alter behavior of the test & its expected output

๐Ÿ”ต Bugs escape such test because test statements were not executed as a condition(s) was not met
{ Lazy Test }

๐ŸŸ  Occurs when multiple test methods invoke the same method of the production object.
{ Resource Optimism }

๐ŸŸ  Occurs when a test method makes an optimistic assumption that the external resource (e.g., File), utilized by the test method, exists or will always be available
{ Assertion Roulette }

๐ŸŸ Occurs when a test method has multiple non-documented assertions

๐Ÿ”ต Multiple assertion statements without a descriptive message impacts readability/maintainability as itโ€™s not possible to understand the reason for the failure of the test
{ Slow Tests }

๐ŸŸ Occurs when tests take longer to run

๐Ÿ”ต It's a quality of a good test to run fast and provide instant feedback to code change
This list is compiled from testsmells.org/. Do check them out for more Smells.
Hello ๐Ÿ‘‹

I am Jaydeep from India ๐Ÿ‡ฎ๐Ÿ‡ณ

Full time Software Engineer & part time content creator on
๐ŸฆTwitter
๐Ÿ–ง Linkedin
๐ŸŽฅYouTube

Follow me for content on
๐Ÿ Python
๐Ÿค–Ai/ML
๐ŸŽจData Visualization
๐ŸŒŸContent creation

Subscribe To My YouTube๐Ÿ”ฝ
youtu.be/FLdS-kBt88M
Mentions
See All