Skip to content

Commit

Permalink
Merge pull request #405 from apptentive/fix-tests
Browse files Browse the repository at this point in the history
Fix SerialDispatchQueueTest, and improve base test logging as well.
  • Loading branch information
skykelsey authored Mar 8, 2017
2 parents 816cf7e + 6533243 commit e76cf9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void testStoppingDispatch() {
dispatchQueue.dispatchAsync(new DispatchTask() {
@Override
protected void execute() {
dispatchQueue.stop();
sleep(500);
addResult("task-1");
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e76cf9e

Please sign in to comment.