arieslab / jnose

JNose - Java TestSmells Detection
GNU General Public License v3.0
20 stars 8 forks source link

Fix Magic Number Test #22

Closed danielevalverde closed 3 years ago

luana-martins commented 4 years ago

Description. Magic Number Test (MNT) occurs when assert statements in a test method contain numeric literals (i.e., magic numbers) as parameters. Magic numbers do not indicate the meaning/purpose of the number. Hence, they should be replaced with constants or variables, thereby providing a descriptive name for the input.

Detection. An assertion that contains a numeric literal as an argument.

Problem. Only one MNT is detected in the test method, even if the test method has multiple assertions with numeric literal as parameters. Fix the test smell detection to count each of its instances and to point the assertion line location.

danielevalverde commented 3 years ago

Hey @luana-martins

Sorry, but I will move this issue to "Doing" again. The problem found was that: Tests the does not contain a literal number within an assert method are being identified as "magic number". Examples:

https://github.com/danielevalverde/jnose-tests/blob/master/src/test/br/ufba/jnose/oracle/CalculateTest.java#L36 https://github.com/danielevalverde/jnose-tests/blob/master/src/test/br/ufba/jnose/oracle/CalculateTest.java#L166