Eclipse导入快捷方式无法按预期工作

时间:2014-10-05 23:42:26

标签: java eclipse junit

我在eclipse kepler中编写了下面的Junit代码。我按下快捷键ctrl+shift+o以自动导入此代码所需的所有包。快捷方式只导入了Test并在assertEquals中给了我一个错误 - The method assertEquals(int, int) is undefined for the type FootballTeamTest

import org.junit.Test;

public class FootballTeamTest {

    @Test
    public void constructorShouldSetGamesWon() {
        FootballTeam team = new FootballTeam(3);
        assertEquals(3, team.getGamesWon());

    }

}

通过添加导入import static org.junit.Assert.*;修复了此问题。为什么eclipse不会自动导入?

相关帖子 - What is a good use case for static import of methods? 在该问题中转到Junit4的答案。惊人的。

0 个答案:

没有答案