All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scalatest.events.Event.scala Maven / Gradle / Ivy

/*
 * Copyright 2001-2013 Artima, 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 org.scalatest.events

import org.scalatest._
import org.scalactic.Requirements._
import java.io.BufferedWriter
import java.io.PrintWriter
import java.io.StringWriter
import java.util.Date
// SKIP-SCALATESTJS,NATIVE-START
import scala.xml.Elem
// SKIP-SCALATESTJS,NATIVE-END
import exceptions.StackDepthException

/**
 * A base class for the events that can be passed to the report function passed
 * to the execute method of a Suite.
 *
 * @author Bill Venners
 */
sealed abstract class Event extends Ordered[Event] with Product with Serializable {

  /**
   * An Ordinal that can be used to place this event in order in the context of
   * other events reported during the same run.
   */
  val ordinal: Ordinal

  /**
   * An optional Formatter that provides extra information that can be used by reporters in determining
   * how to present this event to the user.
   */
  val formatter: Option[Formatter]

  /**
   * An optional Location that provides information indicating where in the source code an event originated.
   * IDEs can use this information, for example, to allow the user to hop from an event report to the relevant
   * line of source code.
   */
  val location: Option[Location]

  /**
   * An optional object that can be used to pass custom information to the reporter about this event.
   */
  val payload: Option[Any]

  /**
   * A name for the Thread about whose activity this event was reported.
   */
  val threadName: String

  /**
   * A Long indicating the time this event was reported, expressed in terms of the
   * number of milliseconds since the standard base time known as "the epoch":
   * January 1, 1970, 00:00:00 GMT.
   */
  val timeStamp: Long

  /**
   * Comparing this event with the event passed as that. Returns
   * x, where x < 0 iff this < that, x == 0 iff this == that, x > 0 iff this > that.
   *
   * @param that the event to compare to this event
   * @param return an integer indicating whether this event is less than, equal to, or greater than
   * the passed event
   */
  def compare(that: Event): Int = ordinal.compare(that.ordinal)

  private [scalatest] def toJson: String

  // SKIP-SCALATESTJS,NATIVE-START
  private [scalatest] def toXml: Elem

  private[events] object EventXmlHelper {
    def stringOption(strOption: Option[String]) = strOption.getOrElse("")
    def longOption(longOption: Option[Long]) = if (longOption.isDefined) longOption.get.toString else ""
    def booleanOption(booleanOption: Option[Boolean]) = if (booleanOption.isDefined) booleanOption.get.toString else ""
    def formatterOption(formatterOption: Option[Formatter]) = {
      formatterOption match {
        case Some(formatter) =>
          formatter match {
            case MotionToSuppress => 
              
            case indentedText: IndentedText => 
              
                 { indentedText.formattedText }
                 { indentedText.rawText }
                 { indentedText.indentationLevel }
              
          }
        case None => ""
      }
    }
    def locationOption(locationOption: Option[Location]) = {
      locationOption match {
        case Some(location) =>
          location match {
            case topOfClass: TopOfClass =>
              
                { topOfClass.className }
              
            case topOfMethod: TopOfMethod =>
              
                { topOfMethod.className }
                { topOfMethod.methodId }
              
            case lineInFile: LineInFile =>
              
                { lineInFile.lineNumber }
                { lineInFile.fileName }
                { filePathnameOption(lineInFile.filePathname) }
              
            case SeeStackDepthException =>
                
            case _ =>
              ""
          }
        case None => ""
      }
    }
    def filePathnameOption(filePathnameOpt: Option[String]) = {
      filePathnameOpt match {
        case Some(filePathname) => filePathname
        case None => ""
      }
    }
    def getThrowableStackDepth(throwable: Throwable) = {
      throwable match { 
        case sde: StackDepthException => sde.failedCodeStackDepth 
        case _ => -1
      }
    }
    def throwableOption(throwableOption: Option[Throwable]) = {
      throwableOption match {
        case Some(throwable) => 
          { throwable.getMessage }
          { getThrowableStackDepth(throwable) }
          
            {
              val stackTraces = throwable.getStackTrace
              for (stackTrace <- stackTraces) yield {
                
                  { stackTrace.getClassName }
                  { stackTrace.getMethodName }
                  { stackTrace.getFileName }
                  { stackTrace.getLineNumber }
                  { stackTrace.isNativeMethod }
                  { stackTrace.toString }
                
              }
              /*val stringWriter = new StringWriter()
              val writer = new PrintWriter(new BufferedWriter(stringWriter))
              throwable.printStackTrace(writer)
              writer.flush()
              stringWriter.toString*/
            }
          
        case None => ""
      }
    }
    def summaryOption(summaryOption: Option[Summary]) = {
      summaryOption match {
        case Some(summary) =>
          { summary.testsSucceededCount }
          { summary.testsFailedCount }
          { summary.testsIgnoredCount }
          { summary.testsPendingCount }
          { summary.testsCanceledCount }
          { summary.suitesCompletedCount }
          { summary.suitesAbortedCount }
          { summary.scopesPendingCount }
        case None => ""
      }
    }
    def nameInfoOption(nameInfoOption: Option[NameInfo]) = {
      nameInfoOption match {
        case Some(nameInfo) => 
          { nameInfo.suiteName }
          { nameInfo.suiteId }
          { stringOption(nameInfo.suiteClassName) }
          { stringOption(nameInfo.testName) }
        case None => 
          ""
      }
    }
  }
  // SKIP-SCALATESTJS,NATIVE-END

  private[events] object EventJsonHelper {

    def getThrowableStackDepth(throwable: Throwable) = {
      throwable match {
        case sde: StackDepthException => sde.failedCodeStackDepth
        case _ => -1
      }
    }

    def string(value: String): String =
      "\"" + value.replaceAllLiterally("""\""", """\\""").replaceAllLiterally("\"", """\"""") + "\""

    def stringOption(valueOpt: Option[String]): String =
      valueOpt match {
        case Some(value) => string(value)
        case None => "null"
      }

    def formatterOption(formatterOption: Option[Formatter]) = {
      formatterOption match {
        case Some(formatter) =>
          formatter match {
            case MotionToSuppress =>
              """{ "formatterType": "MotionToSuppress" }"""
            case indentedText: IndentedText =>
              s"""{ "formatterType": "IndentedText", "formattedText": ${string(indentedText.formattedText)}, "rawText": ${string(indentedText.rawText)}, "indentationLevel": ${indentedText.indentationLevel} }"""
          }
        case None => "null"
      }
    }

    def locationOption(locationOption: Option[Location]) = {
      locationOption match {
        case Some(location) =>
          location match {
            case topOfClass: TopOfClass =>
              s"""{ "locationType": "TopOfClass", "className": ${string(topOfClass.className)} }"""
            case topOfMethod: TopOfMethod =>
              s"""{ "locationType": "TopOfMethod", "className": ${string(topOfMethod.className)}, "methodId": ${string(topOfMethod.methodId)} }"""
            case lineInFile: LineInFile =>
              s"""{ "locationType": "LineInFile", "lineNumber": ${lineInFile.lineNumber}, "fileName": ${string(lineInFile.fileName)}, "filePathname": ${stringOption(lineInFile.filePathname)} }"""
            case SeeStackDepthException =>
              s"""{ "locationType": "SeeStackDepthException" }"""
            case _ =>
              ""
          }
        case None => "null"
      }
    }

    def stackTrace(st: StackTraceElement): String =
      s"""{ "className": ${stringOption(Option(st.getClassName))}, "methodName": ${stringOption(Option(st.getMethodName))}, "fileName": ${stringOption(Option(st.getFileName))}, "lineNumber": ${st.getLineNumber}, "isNative": ${st.isNativeMethod}, "toString": ${stringOption(Option(st.toString))} }"""

    def throwableOption(throwableOption: Option[Throwable]) = {
      throwableOption match {
        case Some(throwable) =>
          s"""{ "className": ${string(throwable.getClass.getName)},  "message": ${stringOption(Option(throwable.getMessage))}, "depth": ${getThrowableStackDepth(throwable)}, "stackTraces": [${throwable.getStackTrace.map(stackTrace).mkString(", ")}] }"""
        case None => "null"
      }
    }

    def summaryOption(summaryOption: Option[Summary]) = {
      summaryOption match {
        case Some(summary) =>
          s"""{ "testsSucceededCount": ${summary.testsSucceededCount}, "testsFailedCount": ${summary.testsFailedCount}, "testsIgnoredCount": ${summary.testsIgnoredCount}, "testsPendingCount": ${summary.testsPendingCount}, "testsCanceledCount": ${summary.testsCanceledCount}, "suitesCompletedCount": ${summary.suitesCompletedCount}, "suitesAbortedCount": ${summary.suitesAbortedCount}, "scopesPendingCount": ${summary.scopesPendingCount} }"""
        case None => "null"
      }
    }

    def nmInfo(nameInfo: NameInfo) =
      s"""{ "suiteName": ${string(nameInfo.suiteName)}, "suiteId": ${string(nameInfo.suiteId)}, "suiteClassName": ${stringOption(nameInfo.suiteClassName)}, "testName": ${stringOption(nameInfo.testName)} }"""

    def nameInfoOption(nameInfoOption: Option[NameInfo]) = {
      nameInfoOption match {
        case Some(nInfo) =>
          nmInfo(nInfo)
        case None =>
          "null"
      }
    }
  }
}

/**
 * Marker trait for test completed event's recordedEvents.
 */
sealed trait RecordableEvent extends Event

/**
 * Marker trait for test failed and test canceled events.
 */
sealed trait ExceptionalEvent extends Event

/**
 * Marker trait for the "notification" events NoteProvided and AlertProvided.
 */
sealed trait NotificationEvent extends Event

/**
 * Event that indicates a suite (or other entity) is about to start running a test.
 *
 * 

* For example, trait Suite uses TestStarting to report * that a test method of a Suite is about to be invoked. *

* *

* To create instances of this class you may use the factory method. For example, * given a report function named report, you could fire a TestStarting event like this: *

* *
 * report(TestStarting(ordinal, userFriendlyName, suiteName, Some(thisSuite.getClass.getName), testName))
 * 
* *

* The suite class name parameter is optional, because suites in ScalaTest are an abstraction that * need not necessarily correspond to one class. Nevertheless, in most cases each suite will correspond * to a class, and when it does, the fully qualified name of that class should be reported by passing a * Some for suiteClassName. One use for this bit of information is JUnit integration, * because the "name" provided to a JUnit org.junit.runner.Description appears to usually include * a fully qualified class name by convention. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param suiteName a localized name identifying the suite containing the test that is starting, suitable for presenting to the user * @param suiteId a string ID for the suite containing the test that is starting, intended to be unique across all suites in a run * @param suiteClassName an optional fully qualifed Suite class name containing the test that is starting * @param testName the name of the test that is starting * @param testText the text of the test that is starting (may be the test name, or a suffix of the test name) * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param rerunner an optional String giving the fully qualified name of the class that can be used to rerun the test that is starting. (If None * is passed, the test cannot be rerun.) * @param payload an optional object that can be used to pass custom information to the reporter about the TestStarting event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class TestStarting ( ordinal: Ordinal, suiteName: String, suiteId: String, suiteClassName: Option[String], testName: String, testText: String, formatter: Option[Formatter] = None, location: Option[Location] = None, rerunner: Option[String] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, suiteName, suiteId, suiteClassName, testName, testText, formatter, location, rerunner, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { suiteName } { suiteId } { stringOption(suiteClassName) } { testName } { testText } { formatterOption(formatter) } { locationOption(location) } { stringOption(rerunner) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "TestStarting", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "testName": ${string(testName)}, "testText": ${string(testText)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a suite (or other entity) has completed running a test that succeeded. * *

* For example, trait Suite uses TestSucceeded to report * that a test method of a Suite returned normally * (without throwing an Exception). *

* *

* To create instances of this class you may use the factory method. For example, given a * report function named report, you could fire a TestSucceeded event like this: *

* *
 * report(TestSucceeded(ordinal, userFriendlyName, suiteName, Some(thisSuite.getClass.getName), testName))
 * 
* *

* The suite class name parameter is optional, because suites in ScalaTest are an abstraction that * need not necessarily correspond to one class. Nevertheless, in most cases each suite will correspond * to a class, and when it does, the fully qualified name of that class should be reported by passing a * Some for suiteClassName. One use for this bit of information is JUnit integration, * because the "name" provided to a JUnit org.junit.runner.Description appears to usually include * a fully qualified class name by convention. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param suiteName a localized name identifying the suite containing the test that has succeeded, suitable for presenting to the user * @param suiteId a string ID for the suite containing the test that has succeeded, intended to be unique across all suites in a run * @param suiteClassName an optional fully qualifed Suite class name containing the test that has succeeded * @param testName the name of the test that has succeeded * @param testText the text of the test that has succeeded (may be the test name, or a suffix of the test name) * @param recordedEvents recorded events in the test. * @param duration an optional amount of time, in milliseconds, that was required to run the test that has succeeded * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param rerunner an optional String giving the fully qualified name of the class that can be used to rerun the test that has succeeded. (If None * is passed, the test cannot be rerun.) * @param payload an optional object that can be used to pass custom information to the reporter about the TestSucceeded event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class TestSucceeded ( ordinal: Ordinal, suiteName: String, suiteId: String, suiteClassName: Option[String], testName: String, testText: String, recordedEvents: collection.immutable.IndexedSeq[RecordableEvent], duration: Option[Long] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, rerunner: Option[String] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, suiteName, suiteId, suiteClassName, testName, testText, duration, formatter, location, rerunner, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { suiteName } { suiteId } { stringOption(suiteClassName) } { longOption(duration) } { testName } { testText } { recordedEvents.map(_.toXml) } { formatterOption(formatter) } { locationOption(location) } { stringOption(rerunner) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "TestSucceeded", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "testName": ${string(testName)}, "testText": ${string(testText)}, "recordedEvents" : [${recordedEvents.map(_.toJson).mkString(", ")}], "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a suite (or other entity) has completed running a test that failed. * *

* For example, trait Suite uses TestFailed to report * that a test method of a Suite completed abruptly with an Exception. *

* *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a TestFailed event like this: *

* *
 * report(TestFailed(ordinal, userFriendlyName, message, suiteName, Some(thisSuite.getClass.getName), testName))
 * 
* *

* The suite class name parameter is optional, because suites in ScalaTest are an abstraction that * need not necessarily correspond to one class. Nevertheless, in most cases each suite will correspond * to a class, and when it does, the fully qualified name of that class should be reported by passing a * Some for suiteClassName. One use for this bit of information is JUnit integration, * because the "name" provided to a JUnit org.junit.runner.Description appears to usually include * a fully qualified class name by convention. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param message a localized message suitable for presenting to the user * @param suiteName a localized name identifying the suite containing the test that has failed, suitable for presenting to the user * @param suiteId a string ID for the suite containing the test that has failed, intended to be unique across all suites in a run * @param suiteClassName an optional fully qualifed Suite class name containing the test that has failed * @param testName the name of the test that has failed * @param testText the text of the test that has failed (may be the test name, or a suffix of the test name) * @param recordedEvents recorded events in the test. * @param throwable an optional Throwable that, if a Some, indicates why the test has failed, * or a Throwable created to capture stack trace information about the problem. * @param duration an optional amount of time, in milliseconds, that was required to run the test that has failed * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param rerunner an optional String giving the fully qualified name of the class that can be used to rerun the test that has failed. (If None * is passed, the test cannot be rerun.) * @param payload an optional object that can be used to pass custom information to the reporter about the TestFailed event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class TestFailed ( ordinal: Ordinal, message: String, suiteName: String, suiteId: String, suiteClassName: Option[String], testName: String, testText: String, recordedEvents: collection.immutable.IndexedSeq[RecordableEvent], analysis: collection.immutable.IndexedSeq[String], throwable: Option[Throwable] = None, duration: Option[Long] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, rerunner: Option[String] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event with ExceptionalEvent { requireNonNull(ordinal, message, suiteName, suiteId, suiteClassName, testName, testText, throwable, duration, formatter, location, rerunner, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { message } { suiteName } { suiteId } { stringOption(suiteClassName) } { longOption(duration) } { testName } { testText } { recordedEvents.map(_.toXml) } analysis.map(a => a) { throwableOption(throwable) } { formatterOption(formatter) } { locationOption(location) } { stringOption(rerunner) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "TestFailed", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "testName": ${string(testName)}, "testText": ${string(testText)}, "recordedEvents" : [${recordedEvents.map(_.toJson).mkString(", ")}], "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a suite (or other entity) has ignored a test. * *

* For example, trait Suite uses TestIgnored to report * that a test method of a Suite was ignored because it was annotated with @Ignore. * Ignored tests will not be run, but will usually be reported as reminder to fix the broken test. *

* *

* To create instances of this class you may use the factory method. For example, given a * report function named report, you could fire a TestIgnored event like this: *

* *
 * report(TestIgnored(ordinal, userFriendlyName, suiteName, Some(thisSuite.getClass.getName), testName))
 * 
* *

* The suite class name parameter is optional, because suites in ScalaTest are an abstraction that * need not necessarily correspond to one class. Nevertheless, in most cases each suite will correspond * to a class, and when it does, the fully qualified name of that class should be reported by passing a * Some for suiteClassName. One use for this bit of information is JUnit integration, * because the "name" provided to a JUnit org.junit.runner.Description appears to usually include * a fully qualified class name by convention. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param suiteName a localized name identifying the suite containing the test that was ignored, suitable for presenting to the user * @param suiteId a string ID for the suite containing the test that was ignored, intended to be unique across all suites in a run * @param suiteClassName an optional fully qualifed Suite class name containing the test that was ignored * @param testName the name of the test that was ignored * @param testText the text of the test that was ignored (may be the test name, or a suffix of the test name) * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the TestIgnored event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class TestIgnored ( ordinal: Ordinal, suiteName: String, suiteId: String, suiteClassName: Option[String], testName: String, testText: String, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, suiteName, suiteId, suiteClassName, testName, testText, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { suiteName } { suiteId } { stringOption(suiteClassName) } { testName } { testText } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "TestIgnored", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "testName": ${string(testName)}, "testText": ${string(testText)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a test is pending, i.e., it hasn't yet been implemented. * *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a TestPending event like this: *

* *
 * report(TestPending(ordinal, userFriendlyName, suiteName, Some(thisSuite.getClass.getName), testName))
 * 
* *

* The suite class name parameter is optional, because suites in ScalaTest are an abstraction that * need not necessarily correspond to one class. Nevertheless, in most cases each suite will correspond * to a class, and when it does, the fully qualified name of that class should be reported by passing a * Some for suiteClassName. One use for this bit of information is JUnit integration, * because the "name" provided to a JUnit org.junit.runner.Description appears to usually include * a fully qualified class name by convention. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param suiteName a localized name identifying the suite containing the test that is pending, suitable for presenting to the user * @param suiteId a string ID for the suite containing the test that is pending, intended to be unique across all suites in a run * @param suiteClassName an optional fully qualifed Suite class name containing the test that is pending * @param testName the name of the test that is pending * @param testText the text of the test that is pending (may be the test name, or a suffix of the test name) * @param recordedEvents recorded events in the test. * @param duration an optional amount of time, in milliseconds, that was required to run the test that is pending * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the TestPending event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class TestPending ( ordinal: Ordinal, suiteName: String, suiteId: String, suiteClassName: Option[String], testName: String, testText: String, recordedEvents: collection.immutable.IndexedSeq[RecordableEvent], duration: Option[Long] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, suiteName, suiteId, suiteClassName, testName, testText, duration, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { suiteName } { suiteId } { stringOption(suiteClassName) } { longOption(duration) } { testName } { testText } { recordedEvents.map(_.toXml) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "TestPending", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "testName": ${string(testName)}, "testText": ${string(testText)}, "recordedEvents" : [${recordedEvents.map(_.toJson).mkString(", ")}], "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a test was canceled, i.e., it couldn't run because some precondition was not met. * *

* To create instances of this class you may * use the factory methods. For example, given a report function named report, you could fire a TestCanceled event like this: *

* *
 * report(TestCanceled(ordinal, userFriendlyName, suiteName, Some(thisSuite.getClass.getName), testName))
 * 
* *

* The suite class name parameter is optional, because suites in ScalaTest are an abstraction that * need not necessarily correspond to one class. Nevertheless, in most cases each suite will correspond * to a class, and when it does, the fully qualified name of that class should be reported by passing a * Some for suiteClassName. One use for this bit of information is JUnit integration, * because the "name" provided to a JUnit org.junit.runner.Description appears to usually include * a fully qualified class name by convention. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param message a localized message suitable for presenting to the user * @param suiteName a localized name identifying the suite containing the test that was canceled, suitable for presenting to the user * @param suiteId a string ID for the suite containing the test that was canceled, intended to be unique across all suites in a run * @param suiteClassName an optional fully qualifed Suite class name containing the test that was canceled * @param testName the name of the test that was canceled * @param testText the text of the test that was canceled (may be the test name, or a suffix of the test name) * @param recordedEvents recorded events in the test. * @param throwable an optional Throwable that, if a Some, indicates why the test was canceled, * or a Throwable created to capture stack trace information about the problem. * @param duration an optional amount of time, in milliseconds, that was required to run the test that was canceled * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param rerunner an optional String giving the fully qualified name of the class that can be used to rerun the test that has canceled. (If None * is passed, the test cannot be rerun.) * @param payload an optional object that can be used to pass custom information to the reporter about the TestCanceled event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class TestCanceled ( ordinal: Ordinal, message: String, suiteName: String, suiteId: String, suiteClassName: Option[String], testName: String, testText: String, recordedEvents: collection.immutable.IndexedSeq[RecordableEvent], throwable: Option[Throwable] = None, duration: Option[Long] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, rerunner: Option[String] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event with ExceptionalEvent { requireNonNull(ordinal, message, suiteName, suiteId, suiteClassName, testName, testText, duration, throwable, formatter, location, rerunner, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { message } { suiteName } { suiteId } { stringOption(suiteClassName) } { longOption(duration) } { testName } { testText } { recordedEvents.map(_.toXml) } { throwableOption(throwable) } { formatterOption(formatter) } { locationOption(location) } { stringOption(rerunner) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "TestCanceled", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "testName": ${string(testName)}, "testText": ${string(testText)}, "recordedEvents" : [${recordedEvents.map(_.toJson).mkString(", ")}], "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a suite of tests is about to start executing. * *

* For example, trait Suite and object Runner use SuiteStarting to report * that the execute method of a Suite is about to be invoked. *

* *

* To create instances of this class you may use the factory method. For example, given a * report function named report, you could fire a SuiteStarting event like this: *

* *
 * report(SuiteStarting(ordinal, userFriendlyName, suiteName, Some(thisSuite.getClass.getName)))
 * 
* *

* The suite class name parameter is optional, because suites in ScalaTest are an abstraction that * need not necessarily correspond to one class. Nevertheless, in most cases each suite will correspond * to a class, and when it does, the fully qualified name of that class should be reported by passing a * Some for suiteClassName. One use for this bit of information is JUnit integration, * because the "name" provided to a JUnit org.junit.runner.Description appears to usually include * a fully qualified class name by convention. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param suiteName a localized name identifying the suite that is starting, suitable for presenting to the user * @param suiteId a string ID for the suite that is starting, intended to be unique across all suites in a run XXX * @param suiteClassName an optional fully qualifed Suite class name of the suite that is starting * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param rerunner an optional String giving the fully qualified name of the class that can be used to rerun the suite that is starting. (If None * is passed, the suite cannot be rerun.) * @param payload an optional object that can be used to pass custom information to the reporter about the SuiteStarting event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class SuiteStarting ( ordinal: Ordinal, suiteName: String, suiteId: String, suiteClassName: Option[String], formatter: Option[Formatter] = None, location: Option[Location] = None, rerunner: Option[String] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, suiteName, suiteId, suiteClassName, formatter, location, rerunner, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { suiteName } { suiteId } { stringOption(suiteClassName) } { formatterOption(formatter) } { locationOption(location) } { stringOption(rerunner) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "SuiteStarting", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a suite of tests has completed executing. * *

* For example, trait Suite and object Runner use SuiteCompleted to report * that the execute method of a Suite * has returned normally (without throwing a RuntimeException). *

* *

* To create instances of this class you may use the factory method. For example, given a * report function named report, you could fire a SuiteCompleted event like this: *

* *
 * report(SuiteCompleted(ordinal, userFriendlyName, suiteName, Some(thisSuite.getClass.getName)))
 * 
* *

* The suite class name parameter is optional, because suites in ScalaTest are an abstraction that * need not necessarily correspond to one class. Nevertheless, in most cases each suite will correspond * to a class, and when it does, the fully qualified name of that class should be reported by passing a * Some for suiteClassName. One use for this bit of information is JUnit integration, * because the "name" provided to a JUnit org.junit.runner.Description appears to usually include * a fully qualified class name by convention. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param suiteName a localized name identifying the suite that has completed, suitable for presenting to the user * @param suiteId a string ID for the suite that has completed, intended to be unique across all suites in a run * @param suiteClassName an optional fully qualifed Suite class name containing the suite that has completed * @param duration an optional amount of time, in milliseconds, that was required to execute the suite that has completed * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param rerunner an optional String giving the fully qualified name of the class that can be used to rerun the suite that has completed. (If None * is passed, the suite cannot be rerun.) * @param payload an optional object that can be used to pass custom information to the reporter about the SuiteCompleted event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class SuiteCompleted ( ordinal: Ordinal, suiteName: String, suiteId: String, suiteClassName: Option[String], duration: Option[Long] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, rerunner: Option[String] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, suiteName, suiteId, suiteClassName, duration, formatter, location, rerunner, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { suiteName } { suiteId } { stringOption(suiteClassName) } { longOption(duration) } { formatterOption(formatter) } { locationOption(location) } { stringOption(rerunner) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "SuiteCompleted", "ordinal": ${ordinal.runStamp}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates the execution of a suite of tests has aborted, likely because of an error, prior * to completion. * *

* For example, trait Suite and object Runner use SuiteAborted to report * that the execute method of a Suite * has completed abruptly with a RuntimeException. *

* *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a SuiteAborted event like this: *

* *
 * report(SuiteAborted(ordinal, userFriendlyName, message, suiteName, Some(thisSuite.getClass.getName)))
 * 
* *

* The suite class name parameter is optional, because suites in ScalaTest are an abstraction that * need not necessarily correspond to one class. Nevertheless, in most cases each suite will correspond * to a class, and when it does, the fully qualified name of that class should be reported by passing a * Some for suiteClassName. One use for this bit of information is JUnit integration, * because the "name" provided to a JUnit org.junit.runner.Description appears to usually include * a fully qualified class name by convention. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * suite name, suitable for presenting to the user * @param message a localized message suitable for presenting to the user * @param suiteName a localized name identifying the suite that has aborted, suitable for presenting to the user * @param suiteId a string ID for the suite that has aborted, intended to be unique across all suites in a run * @param suiteClassName   an optional fully qualifed Suite class name containing the suite that has aborted * @param throwable an optional Throwable that, if a Some, indicates why the suite has aborted, * or a Throwable created to capture stack trace information about the problem. * @param duration an optional amount of time, in milliseconds, that was required to execute the suite that has aborted * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location an optional Location that provides information indicating where in the source code an event originated. * @param rerunner an optional String giving the fully qualified name of the class that can be used to rerun the suite that has aborted. (If None * is passed, the suite cannot be rerun.) * @param payload an optional object that can be used to pass custom information to the reporter about the SuiteAborted event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class SuiteAborted ( ordinal: Ordinal, message: String, suiteName: String, suiteId: String, suiteClassName: Option[String], throwable: Option[Throwable] = None, duration: Option[Long] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, rerunner: Option[String] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event with ExceptionalEvent { requireNonNull(ordinal, message, suiteName, suiteId, suiteClassName, throwable, duration, formatter, location, rerunner, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { message } { suiteName } { suiteId } { stringOption(suiteClassName) } { longOption(duration) } { throwableOption(throwable) } { formatterOption(formatter) } { locationOption(location) } { stringOption(rerunner) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "SuiteAborted", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "suiteName": ${string(suiteName)}, "suiteId": ${string(suiteId)}, "suiteClassName": ${stringOption(suiteClassName)}, "duration": ${duration.getOrElse("null")}, "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "rerunner": ${stringOption(rerunner)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a runner is about run a suite of tests. * *

* For example, object Runner reports RunStarting to indicate * that the first execute method of a run's initial Suite * is about to be invoked. *

* *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a RunStarting event like this: *

* *
 * report(RunStarting(ordinal, testCount))
 * 
* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param testCount the number of tests expected during this run * @param configMap a ConfigMap of key-value pairs that can be used by custom Reporters * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the RunStarting event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @throws IllegalArgumentException if testCount is less than zero. * * @author Bill Venners */ final case class RunStarting ( ordinal: Ordinal, testCount: Int, configMap: ConfigMap, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, configMap, formatter, location, payload, threadName) if (testCount < 0) throw new IllegalArgumentException("testCount was less than zero: " + testCount) // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { testCount } { for ((key, value) <- configMap) yield { { key } { value } } } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "RunStarting", "ordinal": ${ordinal.runStamp}, "testCount": ${testCount}, "configMap": { ${configMap.map(e => string(e._1) + ": " + string(e._2.toString)).mkString(", ")} }, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a runner has completed running a suite of tests. * *

* Suite's execute method takes a Stopper, whose stopRequested * method indicates a stop was requested. If true is returned by * stopRequested while a suite of tests is running, the * execute method should promptly * return even if that suite hasn't finished running all of its tests. *

* *

If a stop was requested via the Stopper. * Runner will report RunStopped * when the execute method of the run's starting Suite returns. * If a stop is not requested, Runner will report RunCompleted * when the last execute method of the run's starting Suites returns. *

* *

* ScalaTest's Runner fires a RunCompleted report with an empty summary, because * the reporter is responsible for keeping track of the total number of tests reported as succeeded, failed, ignored, pending * and canceled. ScalaTest's internal reporter replaces the RunCompleted with a new one that is identical except * that is has a defined summary. *

* *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a RunCompleted event like this: *

* *
 * report(RunCompleted(ordinal))
 * 
* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param duration an optional amount of time, in milliseconds, that was required by the run that has completed * @param summary an optional Summary of the number of tests that were reported as succeeded, failed, ignored, pending and canceled * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the RunCompleted event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class RunCompleted ( ordinal: Ordinal, duration: Option[Long] = None, summary: Option[Summary] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, duration, summary, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { longOption(duration) } { summaryOption(summary) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "RunCompleted", "ordinal": ${ordinal.runStamp}, "duration": ${duration.getOrElse(0L)}, "summary": ${summaryOption(summary)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a runner has stopped running a suite of tests prior to completion, likely * because of a stop request. * *

* Suite's execute method takes a Stopper, whose stopRequested * method indicates a stop was requested. If true is returned by * stopRequested while a suite of tests is running, the * execute method should promptly * return even if that suite hasn't finished running all of its tests. *

* *

If a stop was requested via the Stopper. * Runner will report RunStopped * when the execute method of the run's starting Suite returns. * If a stop is not requested, Runner will report RunCompleted * when the last execute method of the run's starting Suites returns. *

* *

* ScalaTest's Runner fires a RunStopped report with an empty summary, because * the reporter is responsible for keeping track of the total number of tests reported as succeeded, failed, ignored, * pending and canceled. ScalaTest's internal reporter replaces the RunStopped with a new one that is * identical except that is has a defined summary. *

* *

* To create instances of this class you may use the factory method. For example, given a * report function named report, you could fire a RunStopped event like this: *

* *
 * report(RunStopped(ordinal))
 * 
* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param duration an optional amount of time, in milliseconds, that was required by the run that has stopped * @param summary an optional summary of the number of tests that were reported as succeeded, failed, ignored pending and canceled * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the RunStopped event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class RunStopped ( ordinal: Ordinal, duration: Option[Long] = None, summary: Option[Summary] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, duration, summary, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { longOption(duration) } { summaryOption(summary) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "RunStopped", "ordinal": ${ordinal.runStamp}, "duration": ${duration.getOrElse(0L)}, "summary": ${summaryOption(summary)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a runner encountered an error while attempting to run a suite of tests. * *

* For example, object Runner reports RunAborted if the * execute method of any of the run's starting Suites completes * abruptly with a Throwable. *

* *

* ScalaTest's Runner fires a RunAborted report with an empty summary, because * the reporter is responsible for keeping track of the total number of tests reported as succeeded, failed, ignored, and pending. * ScalaTest's internal reporter replaces the RunAborted with a new one that is identical except that is * has a defined summary. *

* *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a RunAborted event like this: *

* *
 * report(RunAborted(ordinal, message, Some(exception)))
 * 
* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param message a localized message suitable for presenting to the user * @param throwable an optional Throwable that, if a Some, indicates why the run has aborted, * or a Throwable created to capture stack trace information about the problem. * @param duration an optional amount of time, in milliseconds, that was required by the run that has aborted * @param summary an optional Summary of the number of tests that were reported as succeeded, failed, ignored, and pending * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the RunAborted event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class RunAborted ( ordinal: Ordinal, message: String, throwable: Option[Throwable], duration: Option[Long] = None, summary: Option[Summary] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, message, throwable, duration, summary, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { message } { throwableOption(throwable) } { longOption(duration) } { summaryOption(summary) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "RunAborted", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "throwable": ${throwableOption(throwable)}, "duration": ${duration.getOrElse(0L)}, "summary": ${summaryOption(summary)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event used to provide information that is not appropriate to report via any other Event. * *

* To create instances of this class you may * use the factory method provided in its companion object. For example, given a * report function named report, you could fire a InfoProvided event like this: *

* *
 * report(InfoProvided(ordinal, message, Some(NameInfo(suiteName, suiteId, Some(thisSuite.getClass.getName), Some(testName)))))
 * 
* *

* An InfoProvided event may be fired from anywhere. In this respect InfoProvided is different * from events for which it is defined whether they are fired in the context of a suite or test. * If fired in the context of a test, the InfoProvided event should include a NameInfo in which * testName is defined. If fired in the context of a suite, but not a test, the InfoProvided event * should include a NameInfo in which testName is not defined. If fired within the context * of neither a suite nor a test, the nameInfo of the InfoProvided event (an Option[NameInfo]) should be None. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param message a localized message suitable for presenting to the user * @param nameInfo an optional NameInfo that if defined, provides names for the suite and optionally the test * in the context of which the information was provided * @param throwable an optional Throwable * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the InfoProvided event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class InfoProvided ( ordinal: Ordinal, message: String, nameInfo: Option[NameInfo], throwable: Option[Throwable] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends RecordableEvent { requireNonNull(ordinal, message, nameInfo, throwable, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { message } { nameInfoOption(nameInfo) } { throwableOption(throwable) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "InfoProvided", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nameInfoOption(nameInfo)}, "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event used to provide alert notifications. * *

* To create instances of this class you may use the factory method. For example, given a * report function named report, you could fire an AlertProvided event like this: *

* *
 * report(AlertProvided(ordinal, message, Some(NameInfo(suiteName, suiteId, Some(thisSuite.getClass.getName), Some(testName)))))
 * 
* *

* AlertProvided differs from InfoProvided in that unlike InfoProvided, AlertProvided isn't * a RecordableEvent. If fired becase of an alert call from a test, for example, the AlertProvided will immediately * be sent to the reporters rather than being stored and sent in the recordedEvents field of the test completion event. Thus, * AlertProvided enables "status notifications" to be provided * while tests are happening. The difference between AlertProvided and NoteProvided, which is also a "status notification" * fired immediately during tests, is that AlertProvided is intended for warnings, where as NoteProvided is just * for information. As an illustration, AlertProvided messages are displayed in yellow, NoteProvided in green, * in the stdout, stderr, and file reporters. *

* *

* An AlertProvided event may be fired from anywhere. In this respect AlertProvided is different * from events for which it is defined whether they are fired in the context of a suite or test. * If fired in the context of a test, the AlertProvided event should include a NameInfo in which * testName is defined. If fired in the context of a suite, but not a test, the AlertProvided event * should include a NameInfo in which testName is not defined. If fired within the context * of neither a suite nor a test, the nameInfo of the AlertProvided event (an Option[NameInfo]) should be None. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param message a localized message suitable for presenting to the user * @param nameInfo an optional NameInfo that if defined, provides names for the suite and optionally the test * in the context of which the information was provided * @param throwable an optional Throwable * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the AlertProvided event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class AlertProvided ( ordinal: Ordinal, message: String, nameInfo: Option[NameInfo], throwable: Option[Throwable] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends NotificationEvent { requireNonNull(ordinal, message, nameInfo, throwable, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { message } { nameInfoOption(nameInfo) } { throwableOption(throwable) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "AlertProvided", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nameInfoOption(nameInfo)}, "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event used to provide notifications. * *

* To create instances of this class you may use the factory method. For example, given a * report function named report, you could fire a NoteProvided event like this: *

* *
 * report(NoteProvided(ordinal, message, Some(NameInfo(suiteName, suiteId, Some(thisSuite.getClass.getName), Some(testName)))))
 * 
* *

* NoteProvided differs from InfoProvided in that unlike InfoProvided, NoteProvided isn't * a RecordableEvent. If fired because of a note call from a test, for example, the NoteProvided will immediately * be sent to the reporters rather than being stored and sent in the recordedEvents field of the test completion event. Thus, * NoteProvided enables "status notifications" to be provided * while tests are happening. The difference between NoteProvided and AlertProvided, which is also a "status notification" * fired immediately during tests, is that AlertProvided is intended for warnings, where as NoteProvided is just * for information. As an illustration, AlertProvided messages are displayed in yellow, NoteProvided in green, * in the stdout, stderr, and file reporters. *

* *

* An NoteProvided event may be fired from anywhere. In this respect NoteProvided is different * from events for which it is defined whether they are fired in the context of a suite or test. * If fired in the context of a test, the NoteProvided event should include a NameInfo in which * testName is defined. If fired in the context of a suite, but not a test, the NoteProvided event * should include a NameInfo in which testName is not defined. If fired within the context * of neither a suite nor a test, the nameInfo of the NoteProvided event (an Option[NameInfo]) should be None. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param message a localized message suitable for presenting to the user * @param nameInfo an optional NameInfo that if defined, provides names for the suite and optionally the test * in the context of which the information was provided * @param throwable an optional Throwable * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the NoteProvided event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class NoteProvided ( ordinal: Ordinal, message: String, nameInfo: Option[NameInfo], throwable: Option[Throwable] = None, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends NotificationEvent { requireNonNull(ordinal, message, nameInfo, throwable, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { message } { nameInfoOption(nameInfo) } { throwableOption(throwable) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "NoteProvided", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nameInfoOption(nameInfo)}, "throwable": ${throwableOption(throwable)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event used to provide markup text for document-style reports. * *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a MarkupProvided event like this: *

* *
 * report(MarkupProvided(ordinal, text, Some(NameInfo(suiteName, suiteId, Some(thisSuite.getClass.getName), Some(testName)))))
 * 
* *

* A MarkupProvided event may be fired from anywhere. In this respect MarkupProvided is different * from the other events, for which it is defined whether they are fired in the context of a suite or test. * If fired in the context of a test, the MarkupProvided event should include a NameInfo in which * testName is defined. If fired in the context of a suite, but not a test, the MarkupProvided event * should include a NameInfo in which testName is not defined. If fired within the context * of neither a suite nor a test, the nameInfo of the MarkupProvided event (an Option[NameInfo]) should be None. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param text a snippet of markup text (in Markdown format) * @param nameInfo an optional NameInfo that if defined, provides names for the suite and optionally the test * in the context of which the information was provided * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the MarkupProvided event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class MarkupProvided ( ordinal: Ordinal, text: String, nameInfo: Option[NameInfo], formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends RecordableEvent { requireNonNull(ordinal, text, nameInfo, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { text } { nameInfoOption(nameInfo) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "MarkupProvided", "ordinal": ${ordinal.runStamp}, "text": ${string(text)}, "nameInfo": ${nameInfoOption(nameInfo)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a new scope has been opened. * *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a ScopeOpened event like this: *

* *
 * report(ScopeOpened(ordinal, message, Some(NameInfo(suiteName, suiteId, Some(thisSuite.getClass.getName), Some(testName)))))
 * 
* *

* A ScopeOpened event may be fired from within suites or tests. * If fired in the context of a test, the ScopeOpened event should include a NameInfo in which * testName is defined. If fired in the context of a suite, but not a test, the ScopeOpened event * should include a NameInfo in which testName is not defined. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param message a localized message suitable for presenting to the user * @param nameInfo a NameInfo that provides names for the suite and optionally the test * in the context of which the scope was opened * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the ScopeOpened event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class ScopeOpened ( ordinal: Ordinal, message: String, nameInfo: NameInfo, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, message, nameInfo, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { import EventXmlHelper._ { ordinal.runStamp } { message } { nameInfoOption(if (nameInfo != null) Some(nameInfo) else None) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "ScopeOpened", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nmInfo(nameInfo)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a scope has been closed. * *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a ScopeClosed event like this: *

* *
 * report(ScopeClosed(ordinal, message, Some(NameInfo(suiteName, suiteId, Some(thisSuite.getClass.getName), Some(testName)))))
 * 
* *

* A ScopeClosed event may be fired from within suites or tests. * If fired in the context of a test, the ScopeClosed event should include a NameInfo in which * testName is defined. If fired in the context of a suite, but not a test, the ScopeClosed event * should include a NameInfo in which testName is not defined. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param message a localized message suitable for presenting to the user * @param nameInfo a NameInfo that provides names for the suite and optionally the test * in the context of which the scope was closed * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the ScopeClosed event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class ScopeClosed ( ordinal: Ordinal, message: String, nameInfo: NameInfo, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, message, nameInfo, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { message } { nameInfoOption(if (nameInfo != null) Some(nameInfo) else None) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "ScopeClosed", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nmInfo(nameInfo)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a scope is pending. * *

* To create instances of this class you may * use the factory method. For example, given a report function named report, you could fire a ScopePending event like this: *

* *
 * report(ScopePending(ordinal, message, Some(NameInfo(suiteName, Some(thisSuite.getClass.getName), Some(testName)))))
 * 
* *

* A ScopePending event is fired from within suites, and not tests. * The ScopePending event should include a NameInfo in which testName is not defined. *

* * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param message a localized message suitable for presenting to the user * @param nameInfo a NameInfo that provides names for the suite and optionally the test * in the context of which the scope was closed * @param formatter an optional Formatter that provides extra information that can be used by reporters in determining * how to present this event to the user * @param location An optional Location that provides information indicating where in the source code an event originated. * @param payload an optional object that can be used to pass custom information to the reporter about the ScopePending event * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class ScopePending ( ordinal: Ordinal, message: String, nameInfo: NameInfo, formatter: Option[Formatter] = None, location: Option[Location] = None, payload: Option[Any] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, message, nameInfo, formatter, location, payload, threadName) // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { message } { nameInfoOption(if (nameInfo != null) Some(nameInfo) else None) } { formatterOption(formatter) } { locationOption(location) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "ScopePending", "ordinal": ${ordinal.runStamp}, "message": ${string(message)}, "nameInfo": ${nmInfo(nameInfo)}, "formatter": ${formatterOption(formatter)}, "location": ${locationOption(location)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a runner is beginning search for suites to run. * * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param configMap a ConfigMap of key-value pairs that can be used by custom Reporters * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class DiscoveryStarting ( ordinal: Ordinal, configMap: ConfigMap, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, configMap, threadName) /** * Location in a DiscoveryStarting is always set to None. */ val location: Option[Location] = None /** * Payload in a DiscoveryStarting is always set to None. */ val payload: Option[Any] = None /** * Formatter in a DiscoveryStarting is always set to None. */ val formatter: Option[Formatter] = None // SKIP-SCALATESTJS,NATIVE-START private [scalatest] def toXml = { ordinal.runStamp } { for ((key, value) <- configMap) yield { { key } { value } } } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "DiscoveryStarting", "ordinal": ${ordinal.runStamp}, "configMap": { ${configMap.map(e => string(e._1) + ": " + string(e._2.toString)).mkString(", ")} }, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } } /** * Event that indicates a runner has completed searching for suites. * * @param ordinal an Ordinal that can be used to place this event in order in the context of * other events reported during the same run * @param duration an optional amount of time, in milliseconds, that was required by the run that has completed * @param threadName a name for the Thread about whose activity this event was reported * @param timeStamp a Long indicating the time this event was reported, expressed in terms of the * number of milliseconds since the standard base time known as "the epoch": January 1, 1970, 00:00:00 GMT * * @author Bill Venners */ final case class DiscoveryCompleted ( ordinal: Ordinal, duration: Option[Long] = None, threadName: String = Thread.currentThread.getName, timeStamp: Long = (new Date).getTime ) extends Event { requireNonNull(ordinal, duration, threadName) /** * Location in a DiscoveryCompleted is always set to None. */ val location: Option[Location] = None /** * Payload in a DiscoveryCompleted is always set to None. */ val payload: Option[Any] = None /** * Formatter in a DiscoveryCompleted is always set to None. */ val formatter: Option[Formatter] = None // SKIP-SCALATESTJS,NATIVE-START import EventXmlHelper._ private [scalatest] def toXml = { ordinal.runStamp } { longOption(duration) } { threadName } { timeStamp } // SKIP-SCALATESTJS,NATIVE-END private[scalatest] def toJson: String = { import EventJsonHelper._ s"""{ "eventType": "DiscoveryCompleted", "ordinal": ${ordinal.runStamp}, "duration": ${duration.getOrElse(0L)}, "threadName": ${string(threadName)}, "timeStamp": ${timeStamp} }""".stripMargin } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy