Permalink
Browse files

Don't tell TeamCity that a test is running while another test is running

TC6 seems to expect only one test running at a time.
  • Loading branch information...
1 parent abcfce4 commit 6e6bb3e9fa38ab5e708928c7daccfcd280e60fe9 Graham Tackley committed Apr 23, 2012
Showing with 20 additions and 16 deletions.
  1. +20 −16 src/main/scala/com/gu/TeamCityTestReporting.scala
@@ -33,23 +33,27 @@ class TeamCityTestListener extends TestReportListener {
def testEvent(event: TestEvent) {
for (e: TEvent <- event.detail) {
- // this is a lie: the test has already been executed and started by this point,
- // but sbt doesn't send an event when test starts
- teamcityReport("testStarted", "name" -> e.testName)
-
- e.result match {
- case TResult.Success => // nothing extra to report
- case TResult.Error | TResult.Failure =>
- teamcityReport("testFailed",
- "name" -> e.testName,
- "details" -> nicelyFormatException(e.error())
- )
- case TResult.Skipped =>
- teamcityReport("testIgnored", "name" -> e.testName)
- }
-
- teamcityReport("testFinished", "name" -> e.testName)
+ // TC seems to get a bit upset if you start a test while one is already running
+ // so a nasty bit of synchronisation here to stop that happening
+ synchronized {
+ // this is a lie: the test has already been executed and started by this point,
+ // but sbt doesn't send an event when test starts
+ teamcityReport("testStarted", "name" -> e.testName)
+
+ e.result match {
+ case TResult.Success => // nothing extra to report
+ case TResult.Error | TResult.Failure =>
+ teamcityReport("testFailed",
+ "name" -> e.testName,
+ "details" -> nicelyFormatException(e.error())
+ )
+ case TResult.Skipped =>
+ teamcityReport("testIgnored", "name" -> e.testName)
+ }
+
+ teamcityReport("testFinished", "name" -> e.testName)
+ }
}
}

0 comments on commit 6e6bb3e

Please sign in to comment.