0

나는 클라이언트와 서버라는 두 개의 프로젝트로 구성된 간단한 게임을 가지고있다. 이제 그들이 제대로 상호 작용하는지 테스트하고 싶습니다. 설치 위치 : 하나의 Maven-parent 프로젝트 및 child-modules로서의 server/client/integetion-test.
이 가이드 http://docs.codehaus.org/display/MAVENUSER/Maven+and+Integration+Testing을 따르려고했는데, 이것은 maven-failsafe-plugin을 사용하는 통합 testin입니다. 슬프게도 그것은 단지 플러그인으로 사용할 수있는 부두 - 서버를 시작하는 방법을 설명하는 것입니다.Maven을 이용한 클라이언트 - 서버 통합 테스트

테스트를 위해이 구성에서 내 클라이언트와 서버를 시작하는 방법과 위치는 어디에서 (또는 더 좋습니까?)? 나는 이런 식으로하고 싶었다. 우선 테스트 전에 클라이언트와 서버를 시작하고 싶다. jUnittest에서는 Socket과 Serversocket을 하나 갖고 싶습니다. 하나는 서버에 연결하고 다른 하나는 클라이언트에 연결합니다. 그런 다음이 설정을 통해 클라이언트/서버 상호 작용을 파이프하여 중간에 확인하거나 개별 메시지를 개별적으로 전송하여 응답을 확인합니다.

가능한가요 아니면 더 좋은 방법이 있습니까?

답변

1

나는 이전과 비슷한 일을했지만 슬프게도 현재 사용할 수있는 코드가 없습니다. 그러나 그것은 다음과 같습니다. 여기에 사전 통합 테스트에서 ant exec 태스크를 사용하여 서버를 시작하고 통합 후 테스트에서 서버를 중지하십시오.

<plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.7</version> 
    <executions> 
     <execution> 
      <id>start-server</id> 
      <phase>pre-integration-test</phase> 
      <configuration> 
       <target> 
        <exec executable="command to start your server"> 
       </target> 
      </configuration> 
      <goals> 
       <goal>run</goal> 
      </goals> 
     </execution> 
     <execution> 
      <id>stop-server</id> 
      <phase>post-integration-test</phase> 
      <configuration> 
       <target> 
        <exec executable="command to stop your server"> 
       </target> 
      </configuration> 
      <goals> 
       <goal>run</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 
관련 문제