maiflai / gradle-scalatest

A plugin to enable the use of scalatest in a gradle Scala project.
The Unlicense
73 stars 35 forks source link

No errors displayed in reports #22

Closed PixelDuck closed 9 years ago

PixelDuck commented 9 years ago

I am trying to use gradle-scalatest to produce test report. I don't know why, errors are displayed in report from time to time. When i get some initialization error like a bad connection to db, test failed but reports show only successes and no failure at all... any ideas?

maiflai commented 9 years ago

Hi,

It's difficult to say for certain without seeing a build log, and a stacktrace.

In general ScalaTest doesn't like exceptions thrown outside test blocks; it exits the test JVM immediately with an error.

If this is the case then I suggest that you refactor your test code so that it does not have side-effects outside of the test blocks.

This, for example, is a recipe for disaster:

class MyDatabaseSpec extends WordSpec {
  val connection = new Connection(...

Your refactoring may be as quick as using lazy val but in the past I've found that tests like these benefit from a fuller refactoring.

If you need the connection to initialise other Fixture fields, then you probably want to consider wrapping them all in a Fixture that can be initialised with a Connection when the test is executed, rather than when tests are configured.

Does this sound like the issue you are encountering?

Thanks, Stu

PixelDuck commented 9 years ago

Hi I dont know why but the problem is fixed now... sorry for the disturbance