cloudbees에서 ci 용 Maven 기반 Android 프로젝트 설정이 있습니다. My Jenkins의 일은 BitBucket에서 src를 검색 한 후 '설치'목표를 실행하는 것입니다. 모든 것이 잘됩니다. 유일한 문제는 단위 테스트가 실행되지 않는다는 것입니다.Maven에서 cloudbees에 대한 단위 테스트를 수행하지 못했습니다.
IntelliJ에서 정확히 동일한 목표를 (로컬로) 실행하면 단위 테스트를 찾아 실행합니다.
내 치어는 다음과 같다 ->
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.odl</groupId>
<artifactId>GhostRunner</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>GhostRunner</name>
<properties>
<platform.version> 4.1.1.4
</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>2.0-alpha-1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-android</artifactId>
<version>4.45</version>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-core</artifactId>
<version>4.45</version>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-jdbc</artifactId>
<version>4.45</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>16</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
</plugin>
</plugins>
</build>
</project>
이 같은 젠킨스 출력 ->
[INFO] --- maven-surefire-plugin:2.15:test (default-test) @ GhostRunner ---
[INFO] No tests to run.
mojoSucceeded org.apache.maven.plugins:maven-surefire-plugin:2.15(default-test)
[JENKINS] Recording test results
mojoStarted com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0(default-emma)
또 다른 흥미로운 점은 내가 확실한 의존성 여전히 단위 테스트를 제거 할 수 있다는 것입니다 IntelliJ의 설치 목표에 맞게 잘 실행하십시오. 어떤 이유로 Maven은 Jenkins에서 Cloudbees를 실행할 때 테스트를 보지 않고 있습니다.
지혜는 감사하게 받았습니다. 여기
는 cloudbees 말을 ::했다 무엇
여기서 문제는 IntelliJ에 당신 의 테스트 클래스를 컴파일하고 $ {project.build.testOutputDirectory}에 대한에 해당 클래스를 가하고 있다는 점이다 당신.
당신은이 문제를 해결하는 방법은 두 가지가 있습니다
(라이프 사이클 목표에 클릭하는 동안 ⌘를 보유) 인 IntelliJ가 깨끗한 설치 실행 얻어서 로컬이 실패를 복제 할 수 있습니다.
는 테스트 소스가 표준 위치에 있지 않은 것을 메이븐에게
표준 제자리에 테스트 소스를 넣습니다.
아파치 메이븐 팀 또는 Codehaus 모조 팀 를 작성하지 일부 플러그인을 많이 다루고는 표준 디렉토리 레이아웃으로가는 가장 좋은 방법입니다. Apache Maven 또는 Codehaus Mojo 커뮤니티에 대한 리뷰의 대상인 플러그인은 보통 비표준 레이아웃을 사용 중이라고 Maven에 알릴 때 은 변경 사항을 적용합니다. 해당 리뷰 프로세스의 적용을받지 않는 플러그인은 은 제대로 작동하는 방법을 모르는 경우가 많으므로 이 표준 레이아웃과 맞춰야합니다. 나는 메이븐 규범을 반영하기 위해 내 프로젝트를 다시 구성했습니다하지만 여전히 cloudbees 서버에서 테스트를 실행하지 스티븐 코놀리 CloudBees, Inc의
.
여기
없음 소스는 어떻게 든
컴파일 할 젠킨스 콘솔 출력 ::
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ GhostRunner ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /scratch/jenkins/workspace/ghost runner/src/test/resources
mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-testResources)
mojoStarted org.apache.maven.plugins:maven-compiler-plugin:3.0(default-testCompile)
[INFO] No sources to compile
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ GhostRunner ---
mojoSucceeded org.apache.maven.plugins:maven-compiler-plugin:3.0(default-testCompile)
mojoStarted org.apache.maven.plugins:maven-surefire-plugin:2.15(default-test)
[INFO]
[INFO] --- maven-surefire-plugin:2.15:test (default-test) @ GhostRunner ---
[INFO] No tests to run.
내가 중요한 비트가 생각에서 관련 출력하지 여전히 않습니다이다 테스트가 어디에 있는지 알 수 있습니다.
단위 테스트를 어디에서 찾았습니까? 'src/test/java'라고 이름을 붙이고 ['* Test * .java','* Test.java','* TestCase.java']와 같은 이름을 붙였습니다. (http://maven.apache.org/surefire/maven -surefire-plugin/test-mojo.html # includes). – khmarbaise
은/src/test에 있으며 모두 테스트 형식으로 이름이 지정됩니다. 테스트 폴더 아래의 java 폴더가 중요하다고 생각하십니까? –
예, 필요합니다. [Maven의 기본 설정] (http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html)'src/main/java'입니다. 단위 테스트를위한 생산 코드'src/test/java'. 생산 코드에서 사용할 수있는 리소스는'src/main/resources'를, 유닛 테스트에서는 리소스를 위해'src/test/resources'를 추가합니다. – khmarbaise