在circle-ci上运行Robotium测试时测试FAILED

时间:2016-10-24 19:50:27

标签: android robotium circleci

这是我的circleci config file

# Build configuration file for Circle CI
# needs to be named `circle.yml` and should be in the top level dir of the repo

general:
  artifacts:
    - "~/build_output.zip" # Save APK's, Lint Results, and Test Results

machine:
  environment:
    ANDROID_HOME: /usr/local/android-sdk-linux
  java:
    version: oraclejdk8

dependencies:
  cache_directories:
    - ~/.android
    - ~/android
  override:
    - (echo "Downloading Android SDK v24...")
    - (source environmentSetup.sh && getAndroidSDK)

test:
  override:
    # 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 connectedAndroidTest
    # run jUnit tests
    - ./gradlew test
    # copy the build outputs to artifacts
    - cp -r app/build/outputs $CIRCLE_ARTIFACTS
    # copy the test results to the test results directory.
    - cp -r app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS

这是test method

@Test
public void test_ListRepos_ClickOnOneRepo_DisplayDetailWithOnlyThisRepo() {
    Given:
    {
        final String lsOneRepoJSONData = mLocalifyClient.localify().loadRawFile(fr.guddy.androidstarter.test.R.raw.repos_octocat);
        final MockResponse loMockResponseWithOneRepo = new MockResponse().setResponseCode(200);
        loMockResponseWithOneRepo.setBody(lsOneRepoJSONData);
        mMockWebServer.enqueue(loMockResponseWithOneRepo);
        try {
            mMockWebServer.start(4000);
        } catch (@NonNull final Exception loException) {
            loException.printStackTrace();
        }
        mActivity = mActivityTestRule.launchActivity(null);
    }

    When:
    {
        mSolo.clickOnText("git-consortium");
    }

    Then:
    {
        mSolo.assertCurrentActivity("should be on ActivityRepoDetail", ActivityRepoDetail.class);
        final boolean lbFoundTheRepo = mSolo.waitForText("This repo is for demonstration purposes only.", 1, 5000L, true);
        assertThat(lbFoundTheRepo).isTrue();
    }
}

我在以下版本中遇到测试失败:https://circleci.com/gh/RoRoche/AndroidStarter/tree/master

在本地运行相同的命令,我得到以下结果:

junit.framework.AssertionFailedError:
[
GIVEN A single GitHub repo from the API
WHEN Click on its name and on the back button
THEN It should display the list
]
[
Message: Text string: 'git-consortium' is not found!
]
at junit.framework.Assert.fail(Assert.java:50)
at com.robotium.solo.Clicker.clickOnText(Clicker.java:451)
at com.robotium.solo.Solo.clickOnText(Solo.java:1502)
at fr.guddy.androidstarter.tests.ui.TestActivityRepoList.test_DetailRepos_ClickOnBack_DisplayListRepos(TestActivityRepoList.java:156)

我是否知道如何配置我的circleci构建以使其通过? 提前谢谢。

1 个答案:

答案 0 :(得分:0)

查看其中一个失败的构建的顶部,您将看到以下消息:“您的构建已超过1个容器上的4G内存限制。”。

您的构建内存不足。如果可能的话,我会尝试减少使用的内存量(https://circleci.com/docs/oom/)。如果这是一个拦截器(有时会发生在Android上),我会联系CircleCI支持,看看他们是否可以帮助你。