clairvoyance.specs2.export.Specs2SpecificationList.scala Maven / Gradle / Ivy
The newest version!
package clairvoyance.specs2.export
import org.specs2.main.Arguments
import org.specs2.reporter.DefaultStatisticsRepository
import org.specs2.specification._
import scala.util.Properties._
import scala.xml.NodeSeq
object Specs2SpecificationList extends DefaultStatisticsRepository {
def list(structures: Seq[SpecificationStructure])(implicit args: Arguments): NodeSeq = {
def fragmentsOf(s: SpecificationStructure): Seq[Fragment] =
s.formatFragments(s.map(Fragments.withCreationPaths(Fragments.withSpecName(s.is, s)))).fragments
def resultOfExample(id: SpecIdentification, exampleName: String): NodeSeq = {
- {exampleName}
}
val structure = structures.map { s =>
val stats = s.identification match {
case name: SpecName => getStatistics(name)
}
val cssClass = stats.map(stats => {
if (stats.isSuccess) "test-passed" else if (stats.hasSuspended) "test-not-run" else "test-failed"
}).getOrElse("test-not-run")
val specFragments = fragmentsOf(s).flatMap {
case Text(text, _) => Some({formatShortExampleName(text.raw)} )
case Example(name, _, _, _, _) => Some(resultOfExample(s.identification, formatShortExampleName(name.raw)))
case _ => None
}
- {s.identification.title} ({stats.map(_.displayResults).map(args.colors.removeColors).getOrElse("Not Run")})
{specFragments}
}
{structure}
}
protected def formatShortExampleName: String => String = _.split(lineSeparator).head
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy