2017-10-30 12 views
0

에 나는 MUNIT을 사용하여 작성된 통합 테스트 스위트를 가지고있는 응용 프로그램이 있습니다. 젠킨스를 사용하여 CloudHub에 배포하고 있습니다.구축 후 통합 테스트 뮬

어떻게 테스트 케이스 후 배포를 실행할 수 있습니까?

내가 그것을 받는다는 또는 젠킨스를 사용하여 수행 할 수 또는 사용을 할 수있는 명령 줄 도구가 있습니까?

+0

를 참조하십시오. Jenkins를 통해 CloudHub에 앱을 배포한다고 했으므로 Jenkins를 CloudHub에 배치 한 직후에 통합 테스트를 실행 하시겠습니까? 그렇다면 Jenkins와 함께 CloudHub에 현재 어떻게 배포하고 있습니까? (Maven, 스크립트, 다른 것을 사용하고 있습니까?) –

+0

프로젝트가 현재 이러한 작업에 Maven을 사용하고 있다면, pom.xml을 포함시키는 것이 좋습니다. –

답변

1

pre-integration-test 단계에서 Mule 응용 프로그램을 배포하고 integration-test 단계에서 테스트를 실행하고 post-integration-test 단계에서 테스트를 취소 할 수 있습니다. CloudHub에 배포를 구성하는 방법에 대한 자세한 내용은 Mule Maven plugin documentation를 참조

<plugins> 

    ... 

    <plugin> 
     <groupId>org.mule.tools.maven</groupId> 
     <artifactId>mule-app-maven-plugin</artifactId> 
     <version>1.1</version> 
     <extensions>true</extensions> 
    </plugin> 
    <plugin> 
     <groupId>org.mule.tools.maven</groupId> 
     <artifactId>mule-maven-plugin</artifactId> 
     <version>2.0</version> 
     <configuration> 
      <deploymentType>cloudhub</deploymentType> 
      <!-- muleVersion is the runtime version as it appears on the CloudHub interface --> 
      <muleVersion>3.7.0</muleVersion> 
      <username>myUsername</username> 
      <password>myPassword</password> 
      <redeploy>true</redeploy> 
      <environment>Production</environment> 
     </configuration> 
     <executions> 
      <execution> 
       <id>deploy</id> 
       <phase>pre-integration-test</phase> 
       <goals> 
        <goal>deploy</goal> 
       </goals> 
      </execution> 
      <execution> 
       <id>undeploy</id> 
       <phase>post-integration-test</phase> 
       <goals> 
        <goal>undeploy</goal> 
       </goals> 
      </execution> 
     </executions> 
    </plugin> 
    <plugin> 
      <groupId>com.mulesoft.munit.tools</groupId> 
      <artifactId>munit-maven-plugin</artifactId> 
      <version>${munit.version}</version> 
      <executions> 
       <execution> 
        <id>unit-test</id> 
        <phase>test</phase> 
        <goals> 
         <goal>test</goal> 
        </goals> 
        <configuration> 
         <munittest>.*-unit-test-suite.xml</munittest> 
        </configuration> 
       </execution> 
       <execution> 
        <id>it-test</id> 
        <phase>integration-test</phase> 
        <goals> 
         <goal>test</goal> 
        </goals> 
        <configuration> 
         <munittest>.*-integration-test-suite.xml</munittest> 
        </configuration> 
       </execution> 
      </executions> 
      <configuration> 
       <coverage> 
        <runCoverage>false</runCoverage>> 
       </coverage> 
      </configuration> 
     </plugin> 

    ... 

</plugins> 

: 당신은 같은 것을 사용할 수 있습니다.

EDIT : 테스트를 실행하기 위해 MUnit을 사용할 때 최종 테스트와 차별화되도록 통합 테스트를 실행하려면 MUnit Maven 플러그인을 구성해야합니다. MUnit Maven Support을 참조하십시오. 귀하의 MUNIT 통합 시험은 integration-test 단계에서 실행해야합니다. 빌드를 구성하는 데 문제가있는 경우 주석에 알려 주시면 적절하게 편집하겠습니다.

EDIT2 : 단위 테스트 및 통합 테스트를 모두 수행 할 수있는 MUnit Maven 구성의 실제 예를 제공하기 위해 답을 업데이트했습니다.

구성된 2 개 실행 있습니다

  • 첫번째는 test 상에 실행하고 두 번째는 integration-test에서 실행합니다 (munittest 파라미터를 통해) .*-unit-test-suite.xml 정규식 일치 만 MUNIT 테스트
  • 를 사용가 및 정규 표현식 .*-integration-test-suite.xml과 일치하는 테스트 만 사용하십시오.

그런 다음 단위 테스트와 통합 테스트의 이름을이 패턴에 따라 올바른 순서로 시작해야합니다. 물론 그 예입니다. 중요한 것은 단위 테스트와 통합 테스트가 각각 *Test*IT 클래스를 사용하는 Maven Failsafe 및 Surefire Plugin으로 완료되었으므로 적절한 시점에 차별화되고 실행되도록하는 것입니다.

통합 테스트 만 실행하는 경우이 복잡한 구성을 건너 뛰고 munittest 매개 변수없이 통합 테스트 실행을 사용할 수 있습니다.간단히 말해서

다음과 같이해야 빌드 : MUNIT를 통해

  1. 실행 단위 테스트
  2. 는 Cloudhub에서 응용 프로그램을 배포 (unit-test 실행 단계 test시)을 (deploy 실행 pre-integration-test 단계
  3. 동안
  4. MUnit을 통해 통합 테스트 실행 (실행 중 integration-test 단계)
  5. Cloudhub에서 애플리케이션 배포 취소 당신의 단계와 실행에 익숙하지 않은 경우 post-integration-test 단계

동안 undeploy 실행, 난 그냥 내 대답은 적절하지 않을 수 있다는 것을 깨달았다 Introduction to the Build Lifecycle

+0

Pierre의 답변에 감사드립니다. 우리는 이것을 Anypoint Studio에서 어떻게 시도 할 수 있습니까? –

+0

Maven과의 통합 테스트를 시작하는 가장 좋은 방법은'mvn clean verify' 명령을 실행하는 것입니다. MUnit을 사용함에 따라 pom.xml에 Munit Maven Plugin에 대한 적절한 MUnit 구성을 포함시켜야합니다. 내 답변에 빠진 내용을 편집 할 것입니다. 그러나 Eclipse 또는 Studio와의 통합 테스트를 실행하는 실용적인 방법에 대해서는 알지 못합니다. 일반적으로 단위 테스트는 IDE를 통해 실행됩니다. 이미 터미널이나 셸을 사용하거나 Jenkins를 사용하는 것이 가장 좋습니다. –

+0

피에르 감사합니다. –