/*
 * Copyright 2012-present Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package com.facebook.buck.testrunner;

import com.facebook.buck.test.result.type.ResultType;

/**
 * Result of an individual test method in JUnit. Similar to {@link org.junit.runner.Result}, except
 * that it always corresponds to exactly one test method.
 */
final class TestResult {
  final String testClassName;
  final String testMethodName;
  final long runTime;
  final ResultType type;
  final/* @Nullable */Throwable failure;
  final /* @Nullable */ String stdOut;
  final /* @Nullable */ String stdErr;

  public TestResult(String testClassName,
      String testMethodName,
      long runTime,
      ResultType type,
      /* @Nullable */Throwable failure,
      /* @Nullable */ String stdOut,
      /* @Nullable */ String stdErr) {
    this.testClassName = testClassName;
    this.testMethodName = testMethodName;
    this.runTime = runTime;
    this.type = type;
    this.failure = failure;
    this.stdOut = stdOut;
    this.stdErr = stdErr;
  }

  public boolean isSuccess() {
    return type == ResultType.SUCCESS;
  }
}

@@ -1000,16 +1000,17 @@
 %0A  final
+ 
 /* @Null
@@ -1008,32 +1008,33 @@
  /* @Nullable */
+ 
 Throwable failur
@@ -1250,16 +1250,17 @@
 lable */
+ 
 Throwabl
@@ -1532,16 +1532,16 @@
 stdOut;%0A
-
     this
@@ -1563,16 +1563,789 @@
 r;%0A  %7D%0A%0A
+  public static TestResult forDryRun(String testClassName, String testMethodName) %7B%0A    return new TestResult(%0A        testClassName,%0A        testMethodName,%0A        0,%0A        ResultType.DRY_RUN,%0A        null,%0A        null,%0A        null%0A    );%0A  %7D%0A%0A  public static TestResult forExcluded(String testClassName, String testMethodName, String reason) %7B%0A    return new TestResult(%0A        testClassName,%0A        testMethodName,%0A        0,%0A        ResultType.EXCLUDED,%0A        null,%0A        reason,%0A        null%0A    );%0A  %7D%0A%0A  public static TestResult forDisabled(String testClassName, String testMethodName) %7B%0A    return new TestResult(%0A        testClassName,%0A        testMethodName,%0A        0,%0A        ResultType.DISABLED,%0A        null,%0A        null,%0A        null%0A    );%0A  %7D%0A%0A
   public

Add convenience methods for constructing TestResults.