Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Why did I decide to roll my own exception formatter?

Should now show "caused by"
  • Loading branch information...
commit abcfce4b2cb299a17faf447a43594735d0a5a08e 1 parent 3753426
@tackley tackley authored
View
5 build.sbt
@@ -7,7 +7,7 @@ name := "sbt-teamcity-test-reporting-plugin"
organization := "com.gu"
-version := "1.0"
+version := "1.2"
publishTo <<= (version) { version: String =>
@@ -19,6 +19,3 @@ publishTo <<= (version) { version: String =>
)
)
}
-
-
-version := "1.1-SNAPSHOT"
View
2  readme.md
@@ -18,7 +18,7 @@ To use,
object Plugins extends Build {
lazy val plugins = Project("plugins", file("."))
.dependsOn(
- uri("git://github.com/guardian/sbt-teamcity-test-reporting-plugin.git#1.1")
+ uri("git://github.com/guardian/sbt-teamcity-test-reporting-plugin.git#1.2")
)
}
View
19 src/main/scala/com/gu/TeamCityTestReporting.scala
@@ -4,6 +4,7 @@ import sbt._
import org.scalatools.testing.{Event => TEvent, Result => TResult}
import Keys._
+import java.io.{PrintWriter, StringWriter}
object TeamCityTestReporting extends Plugin {
override def settings = Seq(
@@ -15,9 +16,17 @@ class TeamCityTestListener extends TestReportListener {
/** called for each class or equivalent grouping */
def startGroup(name: String) {
// we can't report to teamcity that a test group has started here,
- // because even if parallel test execution is enabled there may be multiple
- // projects running tests at the same time. So if you tell TC that a test
- // group has started, the tests from different projects will get mixed up.
+ // because even if parallel test execution is disabled there may be multiple
+ // projects running tests from different projects at the same time.
+ // So if you tell TC that a test group has started, the tests from
+ // different projects will get mixed up.
+ }
+
+ def nicelyFormatException(t: Throwable) = {
+ val w = new StringWriter
+ val p = new PrintWriter(w)
+ t.printStackTrace(p)
+ w.toString
}
/** called for each test method or equivalent */
@@ -33,8 +42,8 @@ class TeamCityTestListener extends TestReportListener {
case TResult.Error | TResult.Failure =>
teamcityReport("testFailed",
"name" -> e.testName,
- "details" -> (e.error.toString +
- "\n" + e.error.getStackTrace.mkString("\n at ", "\n at ", "")))
+ "details" -> nicelyFormatException(e.error())
+ )
case TResult.Skipped =>
teamcityReport("testIgnored", "name" -> e.testName)
}
Please sign in to comment.
Something went wrong with that request. Please try again.