누구냐 넌 import static!?
매번 Static 메서드의 클래스를 입력하지 않아도 되는 방법!, 아래 ModelAndViewAssert.assertViewName(...)
처럼.
... import static org.springframework.test.web.ModelAndViewAssert.*; ... @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:spring/test.xml" }) public class ControllerTest { @Autowired private Controller controller; @Test public void viewNameTest() { ModelAndView mav = controller.index(); assertViewName(mav, "/main/index"); } }
static 메소드나 static 변수를 접근하기 위해 해당 클래스의 이름과 함께 써 주어야 한다. 하지만 유틸리티성 메소드나 상수의 경우 일일이 클래스 이름을 써주기 귀찮은 경우가 있는데 이 경우 static import를 사용하면 클래스 이름 없이 static 메소드나 static 변수 이름만으로 사용할 수 있다. Sigel's house made of ice 。。。블로그 본문