scalatest-maven-plugin: Ignore aborted?

130 views
Skip to first unread message

imre...@knowit.no

unread,
Oct 23, 2015, 7:30:17 AM10/23/15
to scalatest-users
Hi,
I have some tests that need a database connection, so I put

before {
  assume
(databaseAvailable)
}

in my suite. This correctly aborts that suite, but results in a failed build. At the same time, I don't want the build to succeed when I have actual failing tests. Is there something like testFailureIgnore, but which only ignores aborted tests, and not failed ones?

Bill Venners

unread,
Oct 23, 2015, 7:33:07 AM10/23/15
to scalate...@googlegroups.com
Hi,

Yes, instead of using a before clause, override withFixture. This will cause a test to be canceled instead of the suite aborted.

The difference between before/after code and withFixture is before code happens *before* the test. Whereas withFixture allows you to insert setup code *at the beginning (or end) of a test. So the test has already started by the time withFixture is invoked, thus you can just cancel that test with an assume. Since the test has *not* yet started when before code is executed, there is no test execution yet to invoke, so the suite aborts instead.

override def withFixture(test: NoArgTest): Outcome = {
  assume(databaseAvailable)
  test()
}

Bill

--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalate...@googlegroups.com
To unsubscribe from this group, send email to
scalatest-use...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Bill Venners
Artima, Inc.
http://www.artima.com
Reply all
Reply to author
Forward
0 new messages