2012-07-11 2 views
0

일련의 RMI 인터페이스/구현에 대한 단위 테스트를 작성하려고 시도 중이며 이러한 테스트를 용이하게하기 위해 Ant + Junit을 사용하고 있습니다. 주된 문제는 내가 내 Junit 작업의 시작 부분에 rmiregistry을 시작하고 실패, 오류 또는 성공 여부와 상관없이 실행 종료시 종료해야한다는 것입니다. Ant 스크립트 :..Ant가 임의의 프로그램을 실행하고 junit 작업이 끝날 때 종료합니다.

<project> 
    <target name="test"> 
     <javac srcdir="Test/src" destdir="Test/bin" /> 
     <junit fork="true" printsummary="true"> 
      <batchtest> 
      <fileset dir="Test/test"> 
       <include name="**/*Test.*"/> 
      </fileset> 
      </batchtest> 
     </junit> 
    </target> 
</project> 
+0

을 당신은 기본적으로 시동 닫 t하는 방법을 알고 계십니까 그는 레지스트리에? – oers

+0

@oers 예'명령 rmiregistry'를 시작하십시오. 레지스트리를 닫으려면 프로세스를 종료합니다. – Woot4Moo

답변

1

는 기본적으로, 단지 시작에 의한 시험을
이 방법 junit이 실패하지 않습니다 JUnit을 작업에 "haltonerror="false"failonerror="false를 설정하고 정지는 exec task을 통해 이루어집니다 내가 여기에서 taskkill 사용.

<exec executable="start"> <--your start command here --> 
    <arg value="rmiregistry"/> 
</exec> 
<junit fork="true" printsummary="true" haltonerror="false" failonerror="false" errorproperty="juniterrors" failureproperty="junitfailures"> 
    ... 
</junit> 
<exec executable="taskkill"> <--your shutdown command here --> 
    <arg value="/IM"/> 
    <arg value="rmiregistry.exe"/> 
</exec> 
<fail if="juniterrors"/> <!-- ant can fail now, if desired --> 
<fail if="junitfailures"/> 

또 다른 옵션은 try/catch from ant-contrib을 사용하는 것입니다. rmiregistry.exe을 죽이고,하지만 난이 여기에 필요하다 생각하지 않습니다.

관련 문제