perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.63k stars 1.56k forks source link

Test improvement: removed Magic Number test smell #1184

Closed gvma closed 3 years ago

gvma commented 3 years ago

This is a test refactoring

Problem: The Magic Number Test occurs when assert() statements in a test method contain numeric literals (i.e., magic numbers) as parameters.

Solution: As magic numbers do not indicate the meaning/purpose of the number, they should be replaced with constants or variables, thereby providing a descriptive name for the input.

Before: Assert.assertEquals(200, response.status); After: Assert.assertEquals(HTTP_OK, response.status);