atrium icon indicating copy to clipboard operation
atrium copied to clipboard

Add lazy message variants for because, feature, Untranslatable, etc

Open vlsi opened this issue 2 years ago • 1 comments

Code related feature

Currently, atrium forces early string instantiation, which does not play nicely with adding descriptions lazily

It would be nice to have something like

expect(2)
  .because { "lazy $message" }
  .toEqual(4)

// For usage like _logic.manualFeature(LazyUntranslatable(messageSupplier), ...
class LazyUntranslatable(
    private val representation: () -> String
): Translatable {
    override val name: String
        get() = getDefault()

    override fun getDefault(): String = representation.invoke()
}

vlsi avatar Feb 23 '23 13:02 vlsi

we had this once for feature but dropped it because the performance win you get is most likely insignificant compared to test setup etc. readable tests and less overloads in the API seemed more important to us. Hence, what is your use case that you want it?

robstoll avatar Feb 23 '23 19:02 robstoll