Skip to content

Commit

Permalink
Merge branch 'fix-null-message-3.2.x' of https://github.com/shawjef3/…
Browse files Browse the repository at this point in the history
…scalatest into 3.2.x-new
  • Loading branch information
cheeseng committed May 4, 2023
2 parents afa8586 + b1217d4 commit 061eda9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Expand Up @@ -62,7 +62,7 @@ private[scalatest] class SuiteRunner(suite: Suite, args: Args, status: ScalaTest
case Failure(ue) =>
status.setFailed() // Don't forward the unreportedException to the returned status, because reporting it here in this SuiteAborted
if (!suite.isInstanceOf[DistributedTestRunnerSuite])
dispatch(SuiteAborted(tracker.nextOrdinal(), ue.getMessage, suite.suiteName, suite.suiteId, Some(suiteClassName), Some(ue), Some(duration), formatter, Some(SeeStackDepthException), suite.rerunner))
dispatch(SuiteAborted(tracker.nextOrdinal(), String.valueOf(ue.getMessage), suite.suiteName, suite.suiteId, Some(suiteClassName), Some(ue), Some(duration), formatter, Some(SeeStackDepthException), suite.rerunner))
}
}
finally status.setCompleted()
Expand Down
Expand Up @@ -129,6 +129,27 @@ class SuiteRunnerSpec extends AnyFunSpec {
assert(rep.suiteAbortedEventsReceived.length == 1)
}

it("should fire SuiteAborted event when afterEach function in BeforeAndAfterEachTestData throws RuntimeException with a null message") {

class ExampleSuite extends AnyFunSuite with BeforeAndAfterEachTestData {

test("test 1") {}

override protected def afterEach(testData: TestData): Unit = {
throw new RuntimeException(null: String)
}

}

val suite = new ExampleSuite
val rep = new EventRecordingReporter
val runner = new SuiteRunner(suite, Args(rep), new ScalaTestStatefulStatus)
runner.run()
assert(rep.suiteStartingEventsReceived.length == 1)
assert(rep.suiteCompletedEventsReceived.length == 0)
assert(rep.suiteAbortedEventsReceived.length == 1)
}

}

}

0 comments on commit 061eda9

Please sign in to comment.