automation test engineers and OOP

My fellow test engineers need to re-read OOP principles and understand their value and really start using them. E.g. they write –

class Epic {
    Type field = new Type();
}

class Test1 extends Epic {
    @Test
    public void test() {
        assertNotNull(field);
    }
}

Enter fullscreen mode Exit fullscreen mode

instead of –

class Epic {
}

class Test1 extends Epic {
    private Type field = new Type();

    @Test
    public void test() {
        assertNotNull(field);
    }
}

Enter fullscreen mode Exit fullscreen mode

Their reasoning is: “When we add another test under this epic and declare the same field, we will get a Sonar issue for duplicate fields.”

My conclusion is they are still not right. You need to declare and initialise fields only in the class where you use it, not in a superclass hoping that someone some day will use it in another child class.

原文链接:automation test engineers and OOP

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容