The Wayback Machine - https://web.archive.org/web/20201015044112/https://github.com/android/android-test/issues/682
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in AndroidGoogleTest.java #682

Open
paladine opened this issue Jul 15, 2020 · 2 comments
Open

NullPointerException in AndroidGoogleTest.java #682

paladine opened this issue Jul 15, 2020 · 2 comments

Comments

@paladine
Copy link

@paladine paladine commented Jul 15, 2020

Description

When I execute my android integration test, I receive a NullPointerException in AndroidGoogleTest. It appears the stackTraceFile argument is null, which is pulled from controller.getDeviceProperties().get("dalvik.vm.stack-trace-file")

My build file

android_binary(
  name = "euchrepay_googleplay_test_binary",
  instruments = "//java/com/jeffreys/euchrepay/googleplay",
  manifest = "AndroidManifest.xml",
  custom_package = "com.jeffreys.euchrepay.googleplay.test",
  deps = ["//javatests/com/jeffreys/common/euchre/ui:test_lib"],
)

android_instrumentation_test(
  name = "euchrepay_googleplay_test",
  target_device = "@android_test_support//tools/android/emulated_devices/generic_phone:google_27_x86_qemu2",
  size = "large",
  args = [
    "--clear_package_data",
  ],
  test_app = ":euchrepay_googleplay_test_binary",
  flaky = True,
)

Sample test

package com.jeffreys.common.euchre.ui;

import static org.junit.Assert.assertNotNull;

import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.jeffreys.common.euchre.android.HelpActivity;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class HelpTest {
  @Rule
  public ActivityTestRule<HelpActivity> activityRule = new ActivityTestRule<>(HelpActivity.class);

  @Test
  public void verifyActivityCanBeCreated() {
    assertNotNull(activityRule.getActivity());
  }
}

Steps to Reproduce

FLAGS="-c opt --incompatible_disable_deprecated_attr_params=false --incompatible_new_actions_api=false --host_force_python=PY2"

bazel test ${FLAGS} --spawn_strategy=standalone --test_timeout=300 //javatests/com/jeffreys/euchrepay/googleplay/...

This is on my system, though reproducing on another system is likely to be a challenge.

Expected Results

Test runs and generates the proper pass/fail results

Actual Results

There was 1 failure:                                                                                                      
1) initializationError(com.google.android.apps.common.testing.suite.AndroidDeviceTestSuite)                               
java.lang.RuntimeException: Failed to create tests for given list of methods:                                             
com.jeffreys.common.euchre.ui.HelpTest#verifyActivityCanBeCreated                                                         
com.jeffreys.common.euchre.ui.PreferencesTest#verifyActivityCanBeCreated                                                  
com.jeffreys.common.euchre.ui.TestGame#testCardLoader                                                                     
com.jeffreys.common.euchre.ui.TestGame#testOnRestart
com.jeffreys.common.euchre.ui.TestGame#testPauseResume
com.jeffreys.common.euchre.ui.TestGame#verifyActivityCreated
com.jeffreys.common.euchre.ui.TestGame#verifyRestart
com.jeffreys.common.euchre.ui.UIUtilTest#verifyCardToDrawableId
com.jeffreys.common.euchre.ui.UIUtilTest#verifySVGLoading
com.jeffreys.common.euchre.ui.UIUtilTest#verifyUniqueIds
com.jeffreys.common.euchre.ui.ViewHandsTest#verifyActivityCreated
com.jeffreys.common.euchre.ui.ViewHandsTest#verifyCount
com.jeffreys.common.euchre.ui.ViewStatsTest#verifyActivityIsCreated
com.jeffreys.common.euchre.ui.ViewStatsTest#verifyListHasItems
com.jeffreys.common.euchre.ui.ViewStatsTest#verifyNumberOfGamesIsShown
        at com.google.android.apps.common.testing.suite.AndroidDeviceTestSuite$Builder.makeNativeTestSuite(AndroidDeviceTe
stSuite.java:188)
        at com.google.android.apps.common.testing.suite.AndroidDeviceTestSuite$Builder.build(AndroidDeviceTestSuite.java:1
03)
        at com.google.android.apps.common.testing.suite.AndroidDeviceTestSuite.suite(AndroidDeviceTestSuite.java:64)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.junit.internal.runners.SuiteMethod.testFromSuiteMethod(SuiteMethod.java:35)
        at org.junit.internal.runners.SuiteMethod.<init>(SuiteMethod.java:24)
        at org.junit.internal.builders.SuiteMethodBuilder.runnerForClass(SuiteMethodBuilder.java:11)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:2
6)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
        at com.google.testing.junit.runner.internal.junit4.MemoizingRequest.createRunner(MemoizingRequest.java:48)
        at com.google.testing.junit.runner.internal.junit4.MemoizingRequest.getRunner(MemoizingRequest.java:34)
        at com.google.testing.junit.runner.junit4.JUnit4TestModelBuilder.get(JUnit4TestModelBuilder.java:49)
        at com.google.testing.junit.runner.junit4.JUnit4TestModelBuilder.get(JUnit4TestModelBuilder.java:27)
        at com.google.testing.junit.runner.util.MemoizingSupplier.get(MemoizingSupplier.java:44)
        at com.google.testing.junit.runner.junit4.JUnit4Runner.run(JUnit4Runner.java:92)
        at com.google.testing.junit.runner.BazelTestRunner.runTestsInSuite(BazelTestRunner.java:153)
        at com.google.testing.junit.runner.BazelTestRunner.main(BazelTestRunner.java:84)
Caused by: java.lang.NullPointerException
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:888)
        at com.google.android.apps.common.testing.suite.AndroidGoogleTest.<init>(AndroidGoogleTest.java:96)
        at com.google.android.apps.common.testing.suite.AndroidGoogleTest.<init>(AndroidGoogleTest.java:58)
        at com.google.android.apps.common.testing.suite.AndroidGoogleTest$Builder.build(AndroidGoogleTest.java:162)
        at com.google.android.apps.common.testing.suite.AndroidDeviceTestSuite$Builder.makeNativeTestSuite(AndroidDeviceTe
stSuite.java:181)
        ... 21 more

AndroidX Test and Android OS Versions

bazel 3.3.1

android_sdk_repository(
    name="androidsdk",
    path="/var/lib/jenkins/tools/android-sdk",
    api_level=29,
    build_tools_version="29.0.3")
...

git_repository(
    name = "android_test_support",
    commit = "e694b99",
    remote = "https://github.com/android/android-test",
)

maven_install(
    artifacts = [
        "androidx.annotation:annotation:1.1.0",
        "androidx.appcompat:appcompat:1.1.0",
        "androidx.fragment:fragment:1.1.0",
        "androidx.preference:preference:1.1.0",
        "androidx.core:core:1.1.0",
        "androidx.test.espresso:espresso-core:3.3.0-rc01",
        "androidx.test.espresso:espresso-idling-resource:3.3.0-rc01",
        "androidx.test:core:1.3.0-rc01",
        "androidx.test.ext:junit:1.1.2-rc01",
        "androidx.test:monitor:1.3.0-rc01",
        "androidx.test:rules:1.3.0-rc01",
        "androidx.test:runner:1.3.0-rc01",
        "com.google.android.gms:play-services-ads:18.2.0",
        "com.google.android.gms:play-services-ads-lite:18.2.0",

        ...
  ]
)

Link to a public git repo demonstrating the problem:

My repo is private

@hoisie
Copy link
Collaborator

@hoisie hoisie commented Jul 17, 2020

Is this 100% reproducible, or just occasionally? Does it work on other devices? Are there any device properties that you are seeing? Does the logcat say anything?

@paladine
Copy link
Author

@paladine paladine commented Jul 28, 2020

This happens 100% of the time - consistently repeatable. There are really no other devices, I'm trying to use the emulator. See my test setup:

Logcat is pretty inconclusive.

logcat4005861797782605868.txt
logcat8201549922190075870.txt
logcat16911063290069669075.txt

android_instrumentation_test(
  name = "euchrepay_googleplay_test",
  target_device = "@android_test_support//tools/android/emulated_devices/generic_phone:google_27_x86_qemu2",
  size = "large",
  args = [
    "--clear_package_data",
  ],
  test_app = ":euchrepay_googleplay_test_binary",
  flaky = True,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.