Thread by Jaydeep Karale
- Tweet
- Feb 5, 2023
- #ComputerProgramming
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 ๐
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
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
๐ต 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
๐ 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
๐ 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
๐ 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.
๐ 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
๐ 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
๐ 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
๐ 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
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
Afiz โก๏ธ @itsafiz
ยท
Feb 5, 2023
Very well written thread as always. ๐๐