Change to call testFailed(testId, failure).

ResultReporter has logic to regard test not executed as "ignored" but it doesn't present in TestFailed(testId, trace) as failure status is not available.

Bug: 162825430
Test: Unit tests
Change-Id: Iedca03d2774889090518627bff84e55d2eb85c7f
Merged-In: Iedca03d2774889090518627bff84e55d2eb85c7f
diff --git a/src/com/android/tradefed/testtype/suite/ModuleDefinition.java b/src/com/android/tradefed/testtype/suite/ModuleDefinition.java
index 9032b00..a3b1c5c 100644
--- a/src/com/android/tradefed/testtype/suite/ModuleDefinition.java
+++ b/src/com/android/tradefed/testtype/suite/ModuleDefinition.java
@@ -747,7 +747,7 @@
             listener.testStarted(testEntry.getKey(), testEntry.getValue().getStartTime());
             switch (testEntry.getValue().getStatus()) {
                 case FAILURE:
-                    listener.testFailed(testEntry.getKey(), testEntry.getValue().getStackTrace());
+                    listener.testFailed(testEntry.getKey(), testEntry.getValue().getFailure());
                     break;
                 case ASSUMPTION_FAILURE:
                     listener.testAssumptionFailure(
@@ -758,7 +758,10 @@
                     break;
                 case INCOMPLETE:
                     listener.testFailed(
-                            testEntry.getKey(), "Test did not complete due to exception.");
+                            testEntry.getKey(),
+                            FailureDescription.create(
+                                    "Test did not complete due to exception.",
+                                    FailureStatus.TEST_FAILURE));
                     break;
                 default:
                     break;
diff --git a/tests/src/com/android/tradefed/testtype/suite/ITestSuiteTest.java b/tests/src/com/android/tradefed/testtype/suite/ITestSuiteTest.java
index 7d89e93..876ba74 100644
--- a/tests/src/com/android/tradefed/testtype/suite/ITestSuiteTest.java
+++ b/tests/src/com/android/tradefed/testtype/suite/ITestSuiteTest.java
@@ -228,7 +228,8 @@
                 TestDescription test = new TestDescription(EMPTY_CONFIG, EMPTY_CONFIG);
                 listener.testStarted(test, 0);
                 if (mFailed != null) {
-                    listener.testFailed(test, mFailed);
+                    listener.testFailed(
+                            test, FailureDescription.create(mFailed, FailureStatus.TEST_FAILURE));
                 }
                 listener.testEnded(test, 5, new HashMap<String, Metric>());
             } finally {
@@ -400,7 +401,8 @@
         TestDescription test = new TestDescription(EMPTY_CONFIG, EMPTY_CONFIG);
         listener.testStarted(test, 0);
         if (testFailed) {
-            listener.testFailed(test, message);
+            listener.testFailed(
+                    test, FailureDescription.create(message, FailureStatus.TEST_FAILURE));
         }
         listener.testEnded(test, 5, new HashMap<String, Metric>());
         listener.testRunEnded(EasyMock.anyLong(), EasyMock.<HashMap<String, Metric>>anyObject());
@@ -416,7 +418,9 @@
             TestDescription test = new TestDescription(EMPTY_CONFIG, EMPTY_CONFIG);
             listener.testStarted(test, 0);
             if (testFailed) {
-                listener.testFailed(test, mTestFailedMessage);
+                listener.testFailed(
+                        test,
+                        FailureDescription.create(mTestFailedMessage, FailureStatus.TEST_FAILURE));
             }
             listener.testEnded(test, 5, new HashMap<String, Metric>());
             listener.testRunEnded(
@@ -1603,7 +1607,9 @@
                     EasyMock.anyLong());
             TestDescription testId = new TestDescription(EMPTY_CONFIG, EMPTY_CONFIG);
             mMockListener.testStarted(testId, 0);
-            mMockListener.testFailed(testId, mTestFailedMessage);
+            mMockListener.testFailed(
+                    testId,
+                    FailureDescription.create(mTestFailedMessage, FailureStatus.TEST_FAILURE));
             mMockListener.testEnded(testId, 5, new HashMap<String, Metric>());
             mMockListener.testRunEnded(
                     EasyMock.anyLong(), EasyMock.<HashMap<String, Metric>>anyObject());
diff --git a/tests/src/com/android/tradefed/testtype/suite/ModuleDefinitionTest.java b/tests/src/com/android/tradefed/testtype/suite/ModuleDefinitionTest.java
index f9c62b5..cc0819d 100644
--- a/tests/src/com/android/tradefed/testtype/suite/ModuleDefinitionTest.java
+++ b/tests/src/com/android/tradefed/testtype/suite/ModuleDefinitionTest.java
@@ -241,7 +241,9 @@
                         continue;
                     }
                     listener.testStarted(test);
-                    listener.testFailed(test, "I failed.");
+                    listener.testFailed(
+                            test,
+                            FailureDescription.create("I failed.", FailureStatus.TEST_FAILURE));
                     listener.testEnded(test, new HashMap<String, Metric>());
                 }
                 listener.testRunEnded(0, new HashMap<String, Metric>());
@@ -542,7 +544,7 @@
                     EasyMock.anyLong(),
                     EasyMock.<HashMap<String, Metric>>anyObject());
         }
-        mMockListener.testFailed(EasyMock.anyObject(), (String) EasyMock.anyObject());
+        mMockListener.testFailed(EasyMock.anyObject(), (FailureDescription) EasyMock.anyObject());
         Capture<FailureDescription> captured = new Capture<>();
         mMockListener.testRunFailed(EasyMock.capture(captured));
         mMockListener.testRunEnded(
@@ -984,7 +986,7 @@
                     EasyMock.anyLong(),
                     EasyMock.<HashMap<String, Metric>>anyObject());
         }
-        mMockListener.testFailed(EasyMock.anyObject(), (String) EasyMock.anyObject());
+        mMockListener.testFailed(EasyMock.anyObject(), (FailureDescription) EasyMock.anyObject());
         mMockListener.testRunFailed((FailureDescription) EasyMock.anyObject());
         mMockListener.testRunEnded(
                 EasyMock.anyLong(), EasyMock.<HashMap<String, Metric>>anyObject());
@@ -1046,7 +1048,7 @@
                     EasyMock.anyLong(),
                     EasyMock.<HashMap<String, Metric>>anyObject());
         }
-        mMockListener.testFailed(EasyMock.anyObject(), (String) EasyMock.anyObject());
+        mMockListener.testFailed(EasyMock.anyObject(), (FailureDescription) EasyMock.anyObject());
         mMockListener.testRunFailed((FailureDescription) EasyMock.anyObject());
         mMockListener.testRunEnded(
                 EasyMock.anyLong(), EasyMock.<HashMap<String, Metric>>anyObject());
@@ -1117,7 +1119,8 @@
                             throws DeviceNotAvailableException {
                         listener.testRunStarted("test", 1);
                         listener.testFailed(
-                                new TestDescription("failedclass", "failedmethod"), "trace");
+                                new TestDescription("failedclass", "failedmethod"),
+                                FailureDescription.create("trace", FailureStatus.TEST_FAILURE));
                     }
                 });
         mTargetPrepList.clear();
@@ -1165,7 +1168,9 @@
                         TestDescription tid = new TestDescription("class", "method");
                         listener.testRunStarted("test", 1);
                         listener.testStarted(tid);
-                        listener.testFailed(tid, "I failed");
+                        listener.testFailed(
+                                tid,
+                                FailureDescription.create("I failed", FailureStatus.TEST_FAILURE));
                         listener.testEnded(tid, new HashMap<String, Metric>());
                         listener.testRunEnded(0, new HashMap<String, Metric>());
                     }
@@ -1322,7 +1327,8 @@
                     public void run(TestInformation testInfo, ITestInvocationListener listener)
                             throws DeviceNotAvailableException {
                         listener.testFailed(
-                                new TestDescription("failedclass", "failedmethod"), "trace");
+                                new TestDescription("failedclass", "failedmethod"),
+                                FailureDescription.create("trace", FailureStatus.TEST_FAILURE));
                     }
                 });
         mTargetPrepList.clear();
@@ -1384,7 +1390,7 @@
                     EasyMock.anyLong(),
                     EasyMock.<HashMap<String, Metric>>anyObject());
         }
-        mMockListener.testFailed(EasyMock.anyObject(), (String) EasyMock.anyObject());
+        mMockListener.testFailed(EasyMock.anyObject(), (FailureDescription) EasyMock.anyObject());
         FailureDescription issues =
                 FailureDescription.create("unresponsive", FailureStatus.LOST_SYSTEM_UNDER_TEST);
         mMockListener.testRunFailed(issues);
@@ -1632,7 +1638,8 @@
                     EasyMock.<HashMap<String, Metric>>anyObject());
             TestDescription testFail0 = new TestDescription(runName + "0class", "fail0");
             mMockListener.testStarted(EasyMock.eq(testFail0), EasyMock.anyLong());
-            mMockListener.testFailed(EasyMock.eq(testFail0), (String) EasyMock.anyObject());
+            mMockListener.testFailed(
+                    EasyMock.eq(testFail0), (FailureDescription) EasyMock.anyObject());
             mMockListener.testEnded(
                     EasyMock.eq(testFail0),
                     EasyMock.anyLong(),
@@ -1653,7 +1660,8 @@
                     EasyMock.<HashMap<String, Metric>>anyObject());
             TestDescription testFail0_1 = new TestDescription(runName + "1class", "fail0");
             mMockListener.testStarted(EasyMock.eq(testFail0_1), EasyMock.anyLong());
-            mMockListener.testFailed(EasyMock.eq(testFail0_1), (String) EasyMock.anyObject());
+            mMockListener.testFailed(
+                    EasyMock.eq(testFail0_1), (FailureDescription) EasyMock.anyObject());
             mMockListener.testEnded(
                     EasyMock.eq(testFail0_1),
                     EasyMock.anyLong(),
@@ -1738,7 +1746,8 @@
             }
             TestDescription testFail0 = new TestDescription(runName + "0class", "fail0");
             mMockListener.testStarted(EasyMock.eq(testFail0), EasyMock.anyLong());
-            mMockListener.testFailed(EasyMock.eq(testFail0), (String) EasyMock.anyObject());
+            mMockListener.testFailed(
+                    EasyMock.eq(testFail0), (FailureDescription) EasyMock.anyObject());
             mMockListener.testEnded(
                     EasyMock.eq(testFail0),
                     EasyMock.anyLong(),
@@ -1763,7 +1772,8 @@
             }
             TestDescription testFail0_1 = new TestDescription(runName + "1class", "fail0");
             mMockListener.testStarted(EasyMock.eq(testFail0_1), EasyMock.anyLong());
-            mMockListener.testFailed(EasyMock.eq(testFail0_1), (String) EasyMock.anyObject());
+            mMockListener.testFailed(
+                    EasyMock.eq(testFail0_1), (FailureDescription) EasyMock.anyObject());
             mMockListener.testEnded(
                     EasyMock.eq(testFail0_1),
                     EasyMock.anyLong(),