Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Introduce TestResult #85

Closed
jcornaz opened this issue Nov 1, 2019 · 0 comments
Closed

Introduce TestResult #85

jcornaz opened this issue Nov 1, 2019 · 0 comments
Assignees
Labels
breaking There is no obvious way to introduce this change without breaking the API

Comments

@jcornaz
Copy link
Owner

jcornaz commented Nov 1, 2019

I said in #51 that:

  • forAll is good because the compile will enforce the assertion (in the form of a predicate)
  • checkForAll is good because using an assertion library such as Kluent or similar gives better message in case of falsification

But it turns out we could have the best of both worlds if the property function returned an TestResult (like the Expectation that must be returned when using elm-test's fuzzer).

With that we could have both: assertion enforced by the compiler and good messages in case of falsification.

So this issue is about introducing the type TestResult and require property tests written with forAny to always return a TestResult.

A minimal starting API could be:

sealed class TestResult {
  object Success : TestResult()
  data class Failure(message: String) : TestResult()
  object Skip : TestResult()
}

fun Boolean?.alwaysTrue(): TestResult = TODO()
fun Boolean?.neverTrue(): TestResult = TODO()
fun Boolean?.alwaysFalse(): TestResult = TODO()
fun Boolean?.neverFalse(): TestResult = TODO()
infix fun <T> T.alwaysEquals(exptected: T): TestResult = TODO()
infix fun <T> T.neverEquals(exptected: T): TestResult = TODO()
@jcornaz jcornaz added the design label Nov 1, 2019
@jcornaz jcornaz changed the title Consider to have a expectForAll with a lambda returning an Expectation Introduce TestResult Jul 24, 2020
@jcornaz jcornaz removed the design label Jul 24, 2020
@jcornaz jcornaz self-assigned this Oct 2, 2020
@jcornaz jcornaz added the breaking There is no obvious way to introduce this change without breaking the API label Nov 18, 2020
@jcornaz jcornaz closed this as completed Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking There is no obvious way to introduce this change without breaking the API
Projects
None yet
Development

No branches or pull requests

1 participant