scalameta / munit

Scala testing library with actionable errors and extensible APIs
https://scalameta.org/munit
Apache License 2.0
429 stars 90 forks source link

Restore v0.7.x fixture ordering #724

Closed valencik closed 10 months ago

valencik commented 10 months ago

:warning: Breaking Change :warning:

This PR changes the ordering in which suite-local fixture afterAll methods are called. It implements the trick @olafurpg describes in https://github.com/scalameta/munit/issues/573#issuecomment-1465269356 to restore the fixture ordering of v0.7.x This ordering was changed in the first v1.0 milestone release Therefore it is a breaking change within the v1.0 milestones in order to avoid a breaking change between v0.7.x and v1.0 overall.

Namely, we split up the suite-local fixture implementation into two fixtures, one of the before* methods, and one for the after* methods. Then we explicitly order munitFixtures to have the befores up front and the afters at the end.

Of particular note, the tests/shared/src/main/scala/munit/FixtureOrderFrameworkSuite.scala file now looks the same as it did before https://github.com/scalameta/munit/pull/430/files?diff=split&w=0#diff-714f7ef13dfbbd4747770936315606f95d8aeba5f24890a45a4be216cda9d8a1

Note: The v0.7.x style ordering is not to run the after* methods in opposite order to how the before* methods were run, making a mirror image like pattern. Instead it's more like after* methods run in the same order as before* methods except for suite-local fixtures which are special cased to run last.