이 기사의 연구에는 주로 Spring+Junit4 인터페이스 테스트의 관련 예가 포함됩니다. 특정 구현 코드는 다음과 같습니다.
<pectionency> <groupId> org.springframework </groupid> <artifactid> spring-context </artifactid> <버전> 4.3.2. Release </version> </dependency> <prectionement> <groupid> org.springframework </groupid> <artifactid> spring-test </expendency </version> 4.3.2. <groupid> junit </groupid> <artifactid> junit </artifactid> <버전> 4.12 </version> </fectionency>
TestInterface는 수동으로 구성되거나 자동 스캔 할 수 있습니다
수동 구성
스프링 구성 파일 구성 :
<bean id = "testinterface"> </bean>
자동 스캔
인터페이스 구현 클래스의 구성
@component public class testinterfaceimpl은 testinterface {스프링 구성 파일 구성
<Context : Annotation-Config/> <Context : Component-Scan Base-Package = "com.xxx.servlet"> </context : component-scan>
import org.junit.test; import org.junit.runner.runwith; org.springframework.test.context.contextConfiguration import; org.springframework.test.context.junit4.springjunit4classrunner; import javax.annotation.resource; @RunWith (SpringJunit4classRunner.class) @ContextConfiguration (locations = "ClassPath : ApplicationContext.xml") 공개 클래스 테스트 {@Resource TestInterface TestInterface; @test public void test1 () {testinterface.test1 (1,2); }위는 Spring+Junit4의 인터페이스 테스트 예제 코드에 대한이 기사의 모든 내용이며 모든 사람에게 도움이되기를 바랍니다. 관심있는 친구는이 사이트의 다른 관련 주제를 계속 참조 할 수 있습니다. 단점이 있으면 메시지를 남겨 두십시오. 이 사이트를 지원해 주신 친구들에게 감사드립니다!