I was writing the Junit code below in eclipse kepler. I pressed the shortcut ctrl+shift+o
to automatically import all the packages that are needed by this code. The shortcut only imported Test and gave me an error in 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());
}
}
This was fixed by adding an import import static org.junit.Assert.*;
. Why does eclipse not do this import automatically ?
Related post - What is a good use case for static import of methods? Go to the answer for Junit4 in that question. Amazing.