■ 펌 & 참고
[Java] static import 이야기
이클립스에서 TDD를 위한 static import 설정
■ JDK 1.5 ( Java 5 ) 에서부터 도입된 static import 는 다른 class 에 있는 static field 나 static method 를 import 하여, 현재 class 에 정의된 것처럼 사용하는 것을 이야기한다. 다시 한번 말하지만, static import 로 import 하려는 field 와 method 는 모두 static 으로 정의되어 있어야 한다. 아래는 assertTrue를 static import 한 모습
import static org.junit.Assert.assertTrue; import org.junit.Test; public class LogbackPilotControllerTest { @Test public void testIndexOf() { String str = "abcdefg"; assertTrue( str.indexOf( "d")>0 ); } }
■ eclipse에서 static import 설정 : Window > Preperences 메뉴에서 Java > Ediotr > Content Assist > Fovorites 에서 New Type 버튼을 선택해서 org.hamcrest.CoreMatchers.*를 static import 하고자 하는 경우 ‘org.hamcrest.CoreMatchers’까지만 입력하고 OK 버튼을 클릭하면 static import가 추가된다.
■ Spring JUnit 테스트시 static import 대상
org.hamcrest.CoreMatchers.* org.junit.Assert.* org.mockito.Mockito.* org.springframework.test.web.servlet.request.MockMvcRequestBuilders.* org.springframework.test.web.servlet.result.MockMvcResultMatchers.*
- Tomcat 시작시 ServletContextListener를 통한 mySQL 접속 2018년 5월 8일
- No grammar constraints (DTD or XML Schema) referenced in the document. 2016년 3월 21일
- Eclipse Warnings – Attribute (cellpadding) is obsolete. Its use is discouraged in HTML5 documents. 2016년 3월 17일
- TIBCO ActiveSpace Eclipse Maven 2016년 3월 16일
- java eclipse static import 2016년 3월 15일
- eclipse plugin 삭제 2016년 3월 14일
- Eclipse 단축키 2016년 3월 3일
- Eclipse SVN 플러그인 설치 – Subversive 2016년 2월 17일
- eclipse svn target ignore 2015년 7월 14일
- eclipse java.lang.OutOfMemoryError: PermGen space 2015년 7월 7일
- facet.IJ2EEFacetConstants error 2015년 1월 2일
- Eclipse Maven Conflict 2015년 1월 1일
- Eclipse SVN plugin 설치 2014년 10월 3일
- tomcat7-maven-plugin 예제 2014년 10월 3일
- eclipse jdk변경(eclipse.ini) 2014년 10월 3일
- Eclipse Spring Maven 2014년 10월 3일
- Install Spring Tool Suite (STS) for Eclipse Luna (4.4) 3.6.1.RELEASE 2014년 10월 3일
- eclipse 실행시 heap size 늘리기(eclipse.ini) 2014년 10월 3일
- eclipse heap size 2014년 10월 3일