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

org.autotdd.engine.JunitUniverse.scala Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package org.autotdd.engine

import java.io.File

trait JunitUniverse[R] extends EngineUniverse[R] {

  trait JUnitManipulator {

    def nuke;
    def append(s: String);
  }

  class JunitFileManipulator(val file: File) extends JUnitManipulator {
    def nuke =
      file.delete()
    def append(s: String) =
      Files.appendToFile(file)((pw) => pw.append(s))
  }

  class JUnitTestManipulator() extends JUnitManipulator {
    var results: List[String] = null
    def nuke =
      if (results == null)
        results = List()
      else
        throw new IllegalStateException;
    def append(s: String) = results = s :: results
  }

  class JunitScenarioReporter(manipulator: JUnitManipulator, displayProcessor: LoggerDisplayProcessor) extends ScenarioVisitor {

    def start = manipulator.nuke

    def visitUseCase(ui: Int, u: UseCase) {
      val text = 

Usecase { ui }: { u.description }

.mkString; manipulator.append(text) } def visitUseCaseEnd(u: UseCase) { } def visitScenario(useCaseindex: Int, u: UseCase, scenarioIndex: Int, s: Scenario) { val paramsString = s.params.mkString("
,") val text =

{ scenarioIndex }{ s.description.collect { case d => ": " + d } getOrElse ("") }

{ if (s.because.isDefined) } { if (s.code.isDefined) } { if (s.assertions.size > 0) }
Parameters{ s.params.mkString(",") }
Expected{ s.expected.getOrElse("") }
Because { s.becauseString } { s.because.get.comment }
Code{ s.code.get.description }{ s.code.get.comment }
Assertions{ s.assertions.mkString(",") }
; val t = text.mkString manipulator.append(t) } def end={} def ifPrint: (String, Node) => String = ??? def elsePrint: (String, Node) => String = ??? def endPrint: (String, Node) => String = ??? } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy