From 65332431c12479b315cedc3316e7d19bcd2cff23 Mon Sep 17 00:00:00 2001 From: skykelsey Date: Tue, 7 Mar 2017 12:02:14 -0800 Subject: [PATCH] Fix SerialDispatchQueueTest, and improve base test logging as well. --- .../sdk/util/threading/SerialDispatchQueueTest.java | 2 +- .../java/com/apptentive/android/sdk/TestCaseBase.java | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apptentive/src/androidTest/java/com/apptentive/android/sdk/util/threading/SerialDispatchQueueTest.java b/apptentive/src/androidTest/java/com/apptentive/android/sdk/util/threading/SerialDispatchQueueTest.java index dd5cca34a..b8dbd1ebc 100644 --- a/apptentive/src/androidTest/java/com/apptentive/android/sdk/util/threading/SerialDispatchQueueTest.java +++ b/apptentive/src/androidTest/java/com/apptentive/android/sdk/util/threading/SerialDispatchQueueTest.java @@ -61,6 +61,7 @@ public void testStoppingDispatch() { dispatchQueue.dispatchAsync(new DispatchTask() { @Override protected void execute() { + dispatchQueue.stop(); sleep(500); addResult("task-1"); } @@ -71,7 +72,6 @@ protected void execute() { addResult("task-2"); } }); - dispatchQueue.stop(); sleep(1000); // wait for the first task to finish assertResult("task-1"); // task-2 should not run diff --git a/apptentive/src/testCommon/java/com/apptentive/android/sdk/TestCaseBase.java b/apptentive/src/testCommon/java/com/apptentive/android/sdk/TestCaseBase.java index 12c27b560..891b42856 100644 --- a/apptentive/src/testCommon/java/com/apptentive/android/sdk/TestCaseBase.java +++ b/apptentive/src/testCommon/java/com/apptentive/android/sdk/TestCaseBase.java @@ -28,13 +28,14 @@ protected void addResult(String str) { } protected void assertResult(String... expected) { - assertEquals("\nExpected: " + StringUtils.join(expected) + - "\nActual: " + StringUtils.join(result), expected.length, result.size()); + // Make sure the expected and result sets contain the same number of items + if (expected.length != result.size()) { + fail(String.format("Expected: [%s], Actual: [%s]", StringUtils.join(expected), StringUtils.join(result))); + } + // Make sure the order and values are the same as well for (int i = 0; i < expected.length; ++i) { - assertEquals("\nExpected: " + StringUtils.join(expected) + - "\nActual: " + StringUtils.join(result), - expected[i], result.get(i)); + assertEquals(String.format("Expected: [%s], Actual: [%s],", StringUtils.join(expected), StringUtils.join(result)), expected[i], result.get(i)); } result.clear();