Romain R. Romain R. - 1 month ago 34
Android Question

Test FAILED when running Robotium tests on circle-ci

Here is my 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


Here is a 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();
}
}


And I get test failures in the following builds: https://circleci.com/gh/RoRoche/AndroidStarter/tree/master

Running the same commands locally, I get the following results:

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)


Any idea of how can I configure my circleci build to make it pass?
Thanks in advance.

Answer

Looking right at the top of one of your failed builds you'll see the following message: "Your build has exceeded the memory limit of 4G on 1 container.".

Your builds are running out of memory. I'd try and reduce the amount of memory used if possible (https://circleci.com/docs/oom/). If that's a blocker (which sometimes happens with Android), I'd contact CircleCI support to see if they can help you out.