diff --git a/sbt/src/sbt-test/tests/junit-xml-report/build.sbt b/sbt/src/sbt-test/tests/junit-xml-report/build.sbt new file mode 100644 index 000000000..9ae00779f --- /dev/null +++ b/sbt/src/sbt-test/tests/junit-xml-report/build.sbt @@ -0,0 +1,38 @@ +import scala.xml.XML +import Tests._ +import Defaults._ + +val checkReport = taskKey[Unit]("Check the test reports") +val checkNoReport = taskKey[Unit]("Check that no reports are present") + +val oneSecondReportFile = "target/test-reports/a.pkg.OneSecondTest.xml" +val failingReportFile = "target/test-reports/another.pkg.FailingTest.xml" + +lazy val root = (project in file(".")). + settings( + scalaVersion := "2.9.2", + libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test", + + // TODO use matchers instead of sys.error + checkReport := { + val oneSecondReport = XML.loadFile(oneSecondReportFile) + if( oneSecondReport.label != "testsuite" ) sys.error("Report should have a root element.") + // somehow the 'success' event doesn't go through... TODO investigate +// if( (oneSecondReport \ "@time").text.toFloat < 1f ) sys.error("expected test to take at least 1 sec") + if( (oneSecondReport \ "@name").text != "a.pkg.OneSecondTest" ) sys.error("wrong test name: " + (oneSecondReport \ "@name").text) + // TODO more checks + + val failingReport = XML.loadFile(failingReportFile) + if( failingReport.label != "testsuite" ) sys.error("Report should have a root element.") + if( (failingReport \ "@failures").text != "2" ) sys.error("expected 2 failures") + if( (failingReport \ "@name").text != "another.pkg.FailingTest" ) sys.error("wrong test name: " + (failingReport \ "@name").text) + // TODO more checks -> the two test cases with time etc.. + + // TODO check console output is in the report + }, + + checkNoReport := { + if( file(oneSecondReportFile).exists() ) sys.error(oneSecondReportFile + " should not exist") + if( file(failingReportFile).exists() ) sys.error(failingReportFile + " should not exist") + } + ) diff --git a/sbt/src/sbt-test/tests/junit-xml-report/project/JUnitXmlReportTest.scala b/sbt/src/sbt-test/tests/junit-xml-report/project/JUnitXmlReportTest.scala deleted file mode 100644 index 42110dda6..000000000 --- a/sbt/src/sbt-test/tests/junit-xml-report/project/JUnitXmlReportTest.scala +++ /dev/null @@ -1,42 +0,0 @@ -import sbt._ -import Keys._ -import scala.xml.XML -import Tests._ -import Defaults._ -import Import._ - -object JUnitXmlReportTest extends Build { - val checkReport = taskKey[Unit]("Check the test reports") - val checkNoReport = taskKey[Unit]("Check that no reports are present") - - private val oneSecondReportFile = "target/test-reports/a.pkg.OneSecondTest.xml" - private val failingReportFile = "target/test-reports/another.pkg.FailingTest.xml" - - lazy val root = Project("root", file("."), settings = defaultSettings ++ Seq( - scalaVersion := "2.9.2", - libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test", - - // TODO use matchers instead of sys.error - checkReport := { - val oneSecondReport = XML.loadFile(oneSecondReportFile) - if( oneSecondReport.label != "testsuite" ) sys.error("Report should have a root element.") - // somehow the 'success' event doesn't go through... TODO investigate -// if( (oneSecondReport \ "@time").text.toFloat < 1f ) sys.error("expected test to take at least 1 sec") - if( (oneSecondReport \ "@name").text != "a.pkg.OneSecondTest" ) sys.error("wrong test name: " + (oneSecondReport \ "@name").text) - // TODO more checks - - val failingReport = XML.loadFile(failingReportFile) - if( failingReport.label != "testsuite" ) sys.error("Report should have a root element.") - if( (failingReport \ "@failures").text != "2" ) sys.error("expected 2 failures") - if( (failingReport \ "@name").text != "another.pkg.FailingTest" ) sys.error("wrong test name: " + (failingReport \ "@name").text) - // TODO more checks -> the two test cases with time etc.. - - // TODO check console output is in the report - }, - - checkNoReport := { - if( file(oneSecondReportFile).exists() ) sys.error(oneSecondReportFile + " should not exist") - if( file(failingReportFile).exists() ) sys.error(failingReportFile + " should not exist") - } - )) -} \ No newline at end of file