2015-10-20 72 views

回答

0

認沽以下,那麼至少你的單元測試應該運行(我沒有在我的項目特濃測試還)

test: override: - export TERM="dumb"; if [ -e ./gradlew ]; then ./gradlew test;else gradle test;fi - cp -r app/build/test-results/* $CIRCLE_TEST_REPORTS

最後一行復制了你的測試結果,以便CircleCI可以分析它們。請務必提供正確的路徑/ build目錄

參考CircleCI文檔的詳細信息和運行模擬器測試 - https://circleci.com/docs/android

1

是,CircleCI可以通過配置circle.yml

支持運行單元和咖啡測試

單元測試

test 
    ./gradlew test 

對於咖啡測試

咖啡噸EST序列是一個涉及多一點,因爲你需要在Android模擬器運行這些測試。

test: 
    pre: 
    # start the emulator 
    - emulator -avd circleci-android22 -no-audio -no-window: 
    background: true 
    parallel: true 
    # wait for it to have booted 
    - circle-android wait-for-boot 
    # unlock the emulator screen 
    - sleep 30 
    - adb shell input keyevent 82 

    override: 
    # run tests against the emulator. 
    - ./gradlew connectedAndroidTest -PdisablePreDex 
+0

我想你建議什麼,但我遇到了錯誤https://circleci.com/gh/adityam7/PopularMovies/21是鏈接到我的CircleCI建在那裏的失敗 –

+0

單元測試注意事項,文檔: _測試Android項目 首先:如果您在存儲庫的根目錄中有一個Gradle包裝,我們將自動運行./gradlew test._ https://circleci.com /docs/1.0/android/#testing-android-projects –

1

我得到了我CircleCI建立同時運行咖啡和單元測試下面是我circle.yml文件

general: 
artifacts: 
    - /home/ubuntu/PopularMovies/app/build/outputs/apk/ 

machine: 
environment: 
    ANDROID_HOME: /usr/local/android-sdk-linux 

dependencies: 
    override: 
     - echo y | android update sdk --no-ui --all --filter tools,platform-tools,android-23,extra-android-m2repository,extra-google-m2repository,extra-google-google_play_services,extra-android-support 
    - echo y | android update sdk --no-ui --all --filter build-tools-23.0.3 

test: 
    override: 

    # perform unit tests 
    - ./gradlew tesMockDebugUnitTest 
    # Save test reports 
    - mkdir -p $CIRCLE_TEST_REPORTS/reports/unit-tests 
    - cp -avr app/build/reports/tests/mockDebug/ $CIRCLE_TEST_REPORTS/reports/unit-tests 
    - mkdir -p $CIRCLE_TEST_REPORTS/junit/ 
    - find . -type f -regex ".*/build/test-results/mockDebug/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; 

    # start the emulator 
    - emulator -avd circleci-android22 -no-audio -no-window: 
     background: true 
     parallel: true 
    # wait for it to have booted 
    - circle-android wait-for-boot 
    # unlock the emulator screen 
    - sleep 30 
    - adb shell input keyevent 82 
    # run tests against the emulator. 
    - ./gradlew connectedMockDebugAndroidTest -PdisablePreDex 
    # Copying the test reports 
    - mkdir -p $CIRCLE_TEST_REPORTS/reports/functional-tests 
    - cp -avr app/build/reports/androidTests/connected/flavors/MOCK/ $CIRCLE_TEST_REPORTS/reports/functional-tests 

您可以查看我的CircleCI建立在https://circleci.com/gh/adityam7/PopularMovies/25

我希望這有助於