Stack overflow when running a test with many `assertTrue`s combined
See original GitHub issueThe following code produces java.lang.StackOverflowError
when you run the test.
object Test extends DefaultRunnableSpec {
def spec = suite("Test")(
test("1") {
val asserts = List.fill(10000)(assertTrue(true))
asserts.reduce(_ && _)
}
)
}
java.lang.StackOverflowError
at zio.test.TestArrow$.$anonfun$run$1(TestArrow.scala:101)
at scala.util.Try$.apply(Try.scala:210)
at zio.test.TestArrow$.attempt(TestArrow.scala:94)
at zio.test.TestArrow$.run(TestArrow.scala:100)
at zio.test.TestArrow$.$anonfun$run$1(TestArrow.scala:113)
at scala.util.Try$.apply(Try.scala:210)
at zio.test.TestArrow$.attempt(TestArrow.scala:94)
at zio.test.TestArrow$.run(TestArrow.scala:100)
...
Happens on both ZIO 1.0.14 and 2.0.0-RC6 (with DefaultRunnableSpec
-> ZIOSpecDefault
).
Issue Analytics
- State:
- Created a year ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Stop requiring only one assertion per unit test
One way to handle this is to refactor the test code into a method that can then be shared between two separate tests....
Read more >Can you have multiple assertEquals(answer, result) in the ...
All asserts will be run, in order. The first assertion to fail causes the test to fail and no further asserts are run...
Read more >Is it OK to have multiple asserts in a single unit test?
The main reason people like to have multiple Assertions is they are trying to have a one [TestFixture] class for each class being...
Read more >Stack Overflow for test while main runs fine : r/rust - Reddit
Hi All, I'm working my way through Advent of code, and I ran into this weird issue while working on Day 03's puzzle....
Read more >JUnit 5 User Guide
Ask JUnit 5 related questions on Stack Overflow or chat with the ... for test cases designed to be invoked multiple times depending...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Because of operators like
And
andOr
this function runs DFS on graph created byTestArrow
in pessimistic case. The only way to make recursive DFS stack safe is to manage stack by yourself AFAIK. If this was up for grabs I’d be happy to help 😃@kitlangton is this still relavent? I didn’t get any answer last time. I think we could use trampolining, either with ZIO object or TailRec from standard Scala.