Not failing a test on first assertion error

11 views
Skip to first unread message

Frank Sommers

unread,
Jun 23, 2017, 1:26:30 PM6/23/17
to scalate...@googlegroups.com
This may have been discussed some time ago, but I don't recall the answer:

Suppose I have a test that tests several assertions. Currently, ScalaTest fails the entire test upon encountering the first assertion failure. Is there a way to:

* Have ScalaTest perform all assertions in a test
* Fail the test if any assertions fail
* List all errors at the time of failing the test

For example:

test("Want to see all errors") {
  assert(1 == 2)
  assert(2 == 3)
}

I'd like it to keep going after the first failure, and then return a message to the effect, e.g., "1 was not 2, 2 was not 3". Is that possible? 

I'm familiar with Scalactic's Accumulator, so I know I can use that, but I wonder if there's a way to do that easily in ScalaTest.

This feature would be useful after a refactoring where several assertions might suddenly fail in a test, and it'd be good to get a quick report of what failed without having to keep re-running the test.

Thanks.

Bill Venners

unread,
Jun 23, 2017, 2:02:40 PM6/23/17
to scalate...@googlegroups.com
Hi Frank,

Checkpoints:

http://doc.scalatest.org/3.0.0/index.html#org.scalatest.Checkpoints

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

Frank Sommers

unread,
Jun 23, 2017, 2:07:47 PM6/23/17
to scalate...@googlegroups.com
Thanks, Bill. Exactly what I was looking for!

-- Frank


> To post to this group, send email to scalatest-users@googlegroups.com

> To unsubscribe from this group, send email to

> 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

> For more options, visit https://groups.google.com/d/optout.



--
Bill Venners
Artima, Inc.
http://www.artima.com

--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalatest-users@googlegroups.com

To unsubscribe from this group, send email to

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-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages