atrium icon indicating copy to clipboard operation
atrium copied to clipboard

migrate away from Spek to kotlin-test

Open robstoll opened this issue 8 months ago • 1 comments

We want to move away from Spek as test-runner as we consider this project dead and it makes more and more problems in conjunction with intellij and gradle. Hence, we migrate the tests in atrium-specs to kotlin-test.

see sub-issues. This issue serves to give an overall view what steps need to be done in the sub issues (this way we can refine the steps at a single place):

Following the things you need to do:

first commit

atrium-specs

  • [ ] rename XyExpectationsSpec to AbstractXyExpectationsTest

atrium-api-fluent/-infix

  • [ ] rename XyExpectationsSpec to XyExpectationsTest
  • [ ] if the XyExpectationsTest contains multiple include (such as ShortcutSpec and BuilderSpec) then split the class into two (or more)

git commit -a -m 'rename ...Spec to ...Test to retain history'

second commit

atrium-specs

  • [ ] add @Suppress("FunctionName") above abstract class AbstractXyExpectationsTest
  • [ ] let AbstractXyExpectationsTest extend ExpectationFunctionBaseTest
  • [ ] append to parameters with type Fun/Feature the suffix Spec (as example rename toContain to toContainSpec)
  • [ ] in case the parameters are Pair<(String -> String), ...> and afterwards assign second to a val, then add the suffix Spec to the val (e.g. val toContainExactly = xyPair.second => val toContainExactlySpec = xyPair.second)
  • [ ] you can remove the describePrefix: String = "[Atrium] " parameter (if defined)
  • [ ] transform the tests (compare AbstractArrayAsListExpectationsTest, AbstractComparableExpectationsTest, or AbstractExtractSubjectTest) with the ..Spec variant
    • [ ] if the Spec contains include(... SubjectLessSpec refactor to
      @TestFactory
      fun subjectLessTest() = subjectLessTestFactory(
      
    • [ ] if the Spec contains include(... AssertionCreatorSpec refactor to
      @TestFactory
      fun expectationCreatorTest() = expectationCreatorTestFactory(
      
    • [ ] replace unifySignature with testFactoryForFeatureNonFeature (see AbstractCollectionExpectationsTest)
    • [ ] replace nonNullableCases with testFactoryNonNullable (see AbstractIterableNotToContainValuesExpectationsTest)
    • [ ] replace describe("iterable ${xyz()....}") with describeIterable(::xyz)
    • [ ] replace context with describe

api-fluent

  • [ ] if the XyExpectationsTest is an object then use class instead
  • [ ] let XyExpectationsTest extend AbstractXyExpectationsTest and adapt
    • [ ] rewrite ambiguityTest:
      • add @Test and remove private (if private)
      • use a proper expect(...) instead of notImplemented()
      • make sure the expectations stated hold (introduce further var .. .= expect() if necessary)
      • Remove explicit type parameters in funX<...> (they used to be necessary but should no longer, was fixed in Kotlin)
    • [ ] if there is no ambiguityTest, then add the following (this way intellij shows the run gutter for this class):
      @Test
      fun trigger_run_gutter() = Unit
      

api-infix

  • [ ] if the XyExpectationsTest is an object then use class instead
  • [ ] let XyExpectationsTest extend AbstractXyExpectationsTest and adapt
    • [ ] rewrite ambiguityTest:
      • add @Test and remove private (if private)
      • use a proper expect(...) instead of notImplemented()
      • make sure the expectations stated hold (introduce further var .. .= expect() if necessary)
      • Remove explicit type parameters in funX<...> (they used to be necessary but should no longer, was fixed in Kotlin)
    • [ ] if there is no ambiguityTest, then add the following (this way intellij shows the run gutter for this class):
      @Test
      fun trigger_run_gutter() = Unit
      

robstoll avatar Apr 23 '25 12:04 robstoll

@hubtanaka, @ragul-engg, @shytnik-igor, @vlsi, @wordhou I could use your help migrating one of those, feel free to assign an issue to yourself if you have time and are in the mood 🙂

robstoll avatar Apr 23 '25 12:04 robstoll