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

im.yagni.driveby.failure.FailureReporter.scala Maven / Gradle / Ivy

The newest version!
package im.yagni.driveby.failure

import im.yagni.driveby.browser.Browser
import im.yagni.driveby.tracking.Tracker
import im.yagni.driveby.{Specification, Example}
import org.joda.time.DateTime
import org.apache.commons.io.FileUtils
import java.io.File

object FailureReporter {
  val reportPath = "target/specs2-reports/failed/"

  def tidyUp() { FileUtils.deleteDirectory(new File(reportPath)) }

  def report(message: String, browser: Browser, example: Example, specification: Specification) {
    val uniqueFailureName = example.id + "_" + specification.name
    val screenshot = new File(reportPath + "screenshot/" + uniqueFailureName + ".png")
    browser.screenshot(screenshot)
    FileUtils.writeStringToFile(new File(reportPath + uniqueFailureName + ".html"), report(message, screenshot, browser, example.id).toString())
  }

  private def report(message: String, screenshot: File, browser: Browser, exampleId: Long) =
    //TODO: include spec name and example desc in report
    
      

{new DateTime}: {message}



{scala.xml.Unparsed(Tracker.allEvents(exampleId).map(e => "

  • " + new DateTime(e.at) + " - " + e + "
  • ").mkString)}


    {scala.xml.Unparsed(browser.html)}

    }




    © 2015 - 2024 Weber Informatics LLC | Privacy Policy