diff --git a/blended.testsupport/src/main/scala/blended/testsupport/scalatest/LoggingFreeSpec.scala b/blended.testsupport/src/main/scala/blended/testsupport/scalatest/LoggingFreeSpec.scala index e1fe45c96..a4cb3467a 100644 --- a/blended.testsupport/src/main/scala/blended/testsupport/scalatest/LoggingFreeSpec.scala +++ b/blended.testsupport/src/main/scala/blended/testsupport/scalatest/LoggingFreeSpec.scala @@ -1,6 +1,7 @@ package blended.testsupport.scalatest import blended.util.logging.Logger +import org.apache.camel.FailedToStartRouteException import org.scalatest.Args import org.scalatest.FreeSpec import org.scalatest.FreeSpecLike @@ -8,27 +9,31 @@ import org.scalatest.Status import org.scalatest.Suite /** - * Same as [[org.scalatest.FreeSpecLike]] but log the start and the end of each test case to SLF4j in Debug level. - * - * @see LoggingFreeSpec - */ + * Same as [[org.scalatest.FreeSpecLike]] but log the start and the end of each test case to SLF4j in Debug level. + * + * @see LoggingFreeSpec + */ trait LoggingFreeSpecLike extends FreeSpecLike { abstract protected override def runTest(testName: String, args: Args): Status = { val log: Logger = Logger[this.type] log.info(s"Starting test case: ${testName}") + var reported = false try { - super.runTest(testName, args) + val status = super.runTest(testName, args) + log.info(s"${if (status.succeeds()) "Finished" else "Failed"} test case: ${testName}") + reported = true + status } finally { - log.info(s"Finished test case: ${testName}") + if (!reported) log.info(s"Finished test case: ${testName}") } } } /** - * Same as [[org.scalatest.FreeSpec]] but log the start and the end of each test case to SLF4j in Debug level. - * - * @see LoggingFreeSpecLike - */ + * Same as [[org.scalatest.FreeSpec]] but log the start and the end of each test case to SLF4j in Debug level. + * + * @see LoggingFreeSpecLike + */ class LoggingFreeSpec extends FreeSpec with LoggingFreeSpecLike