Chromium Code Reviews| Index: testing/android/java/src/org/chromium/testing/local/GtestLogger.java |
| diff --git a/testing/android/java/src/org/chromium/testing/local/GtestLogger.java b/testing/android/java/src/org/chromium/testing/local/GtestLogger.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b56062e7249895c0cd0e544e1363405530dd4f29 |
| --- /dev/null |
| +++ b/testing/android/java/src/org/chromium/testing/local/GtestLogger.java |
| @@ -0,0 +1,95 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.testing.local; |
| + |
| +import org.junit.runner.Description; |
| + |
| +import java.util.Set; |
| + |
| +/** |
| + * Formats and logs test status information in googletest-style. |
| + */ |
| +public class GtestLogger { |
| + |
| + /** |
| + * Logs the start of an individual test. |
| + */ |
| + public static void testStarted(Description test) { |
| + System.out.format("[ RUN ] %s.%s", test.getClassName(), |
|
nyquist
2014/09/19 01:26:03
one line
jbudorick
2014/09/19 20:09:07
Done.
|
| + test.getMethodName()); |
| + System.out.println(); |
| + } |
| + |
| + /** |
| + * Logs the end of an individual test. |
| + */ |
| + public static void testFinished(Description test, boolean passed, |
|
nyquist
2014/09/19 01:26:03
one line
jbudorick
2014/09/19 20:09:07
Done.
|
| + long elapsedTimeMillis) { |
| + if (passed) { |
| + System.out.format("[ OK ] %s.%s (%d ms)", |
| + test.getClassName(), test.getMethodName(), elapsedTimeMillis); |
| + } else { |
| + System.out.format("[ FAILED ] %s.%s (%d ms)", |
| + test.getClassName(), test.getMethodName(), elapsedTimeMillis); |
| + } |
| + System.out.println(); |
| + } |
| + |
| + /** |
| + * Logs the start of a test case. |
| + */ |
| + public static void testCaseStarted(Description test, int testCount) { |
| + System.out.format("[----------] Run %d test cases from %s", testCount, |
|
nyquist
2014/09/19 01:26:03
one line
jbudorick
2014/09/19 20:09:07
Done.
|
| + test.getClassName()); |
| + System.out.println(); |
| + } |
| + |
| + /** |
| + * Logs the end of a test case. |
| + */ |
| + public static void testCaseFinished(Description test, int testCount, |
| + long elapsedTimeMillis) { |
| + System.out.format("[----------] Run %d test cases from %s (%d ms)", |
| + testCount, test.getClassName(), elapsedTimeMillis); |
| + System.out.println(); |
| + System.out.println(); |
| + } |
| + |
| + /** |
| + * Logs the start of a test run. |
| + */ |
| + public static void testRunStarted(int testCount) { |
| + System.out.format("[==========] Running %d tests.", testCount); |
| + System.out.println(); |
| + System.out.println("[----------] Global test environment set-up."); |
| + System.out.println(); |
| + } |
| + |
| + /** |
| + * Logs the end of a test run. |
| + */ |
| + public static void testRunFinished(int passedTestCount, Set<Description> failedTests, |
| + long elapsedTimeMillis) { |
| + int totalTestCount = passedTestCount + failedTests.size(); |
| + System.out.println("[----------] Global test environment tear-down."); |
| + System.out.format("[==========] %d tests ran. (%d ms total)", |
| + totalTestCount, elapsedTimeMillis); |
| + System.out.println(); |
| + System.out.format("[ PASSED ] %d tests.", passedTestCount); |
| + System.out.println(); |
| + if (!failedTests.isEmpty()) { |
| + System.out.format("[ FAILED ] %d tests.", failedTests.size()); |
| + System.out.println(); |
| + for (Description d : failedTests) { |
| + System.out.format("[ FAILED ] %s.%s", d.getClassName(), |
|
nyquist
2014/09/19 01:26:03
one line
jbudorick
2014/09/19 20:09:07
Done.
|
| + d.getMethodName()); |
| + System.out.println(); |
| + } |
| + System.out.println(); |
| + } |
| + } |
| + |
| +} |
| + |