How do I test my JobService with an Instrumentation test?

ぐ巨炮叔叔 提交于 2019-12-03 03:45:57

Thanks to the Google devs being very responsive to answer my question here: https://issuetracker.google.com/issues/62543492, it's now clear how to do it!

It appears that part of the set up of the instrumentation test examples they provided is setting the running app as active and mostly learning about job state via cmd jobscheduler <command> invocations on the shell from the test

    try {
        SystemUtil.runShellCommand(getInstrumentation(), "cmd activity set-inactive "
                + mContext.getPackageName() + " false");
    } catch (IOException e) {
        Log.w("ConstraintTest", "Failed setting inactive false", e);
    }

See the provided InstrumentationTestCase subclass they posted in the bug notes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!