arieslab / jnose

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

Fix Eager Test #26

Closed luana-martins closed 3 years ago

luana-martins commented 3 years ago

Description. Eaget Test (ET) occurs when a test method checks several methods of the object to be tested, it is hard to read and understand, and therefore more difficult to use as documentation. Moreover, it makes tests more dependent on each other and harder to maintain.

Problem. The detection counts as an ET any test method that calls multiple production methods, it does not matter if they are the same production method or not. ET should count only calls for different methods of the object to be tested. Additionally, the detection should point to the lines where the test smell occurs instead of the whole method.

Example. The test method EagerTest is not an ET because it calls the same method chama() twice. The test method trueEager() is an ET because it calls the methods chama() and responde().

public class EagerTest {
    @Test
    public void falseEager() {
        Eager eager = new Eager();
        assertEquals("expected", eager.chama(), "1");
        assertEquals("expected", eager.chama(), "3");
    }

    @Test
    public void trueEager2() {
        Eager eager = new Eager();
        assertEquals("expected", eager.chama(), "1");
        assertEquals("expected", eager.responde(), "1");
    }

}