问题描述
CtsAlarmManagerTestCases
android.alarmmanager.cts.AppStandbyTests#testNeverDelay failed when single run.
java.lang.AssertionError: Alarm received when app was in never bucket
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertFalse(Assert.java:64)
at android.alarmmanager.cts.AppStandbyTests.testNeverDelay(AppStandbyTests.java:257)
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertFalse(Assert.java:64)
at android.alarmmanager.cts.AppStandbyTests.testNeverDelay(AppStandbyTests.java:257)
However it can pass in full run with following command:
run cts -m CtsAlarmManagerTestCases -t android.alarmmanager.cts.AppStandbyTests
解决方案
Google issue.
Following is reason of single fail vs full pass:
Single Fail:
This test case tries to set delay as “never/10 days” with respect to previous alarm trigger by this process
which means alarm must not expire on time.
But alarm gets expires on time because this process doesn’t have any previous alarm so no delay is actually got set.
Full Pass:
In this case, it has previous alarm , already set by CTS test process during previous cts test.
So delay bucket is set as “10 days” successfully and alarm doesn’t expire on time which is expected behavior.