javaru
05/31/2017, 8:12 PMpublic static void assertAll(String heading, Executable... executables)
// "Executable" is an interface with a single "execute()" method
// JAVA
assertAll("test the 'add' method",
() -> assertEquals(4, calculator.add(2, 2)),
() -> assertEquals(5, calculator.add(2, 3))
);
// KOTLIN
# the 'assertEquals' is underscored with error "None of the following functions can be called with the arguments supplied."
assertAll("test the 'add' method",
{ assertEquals(4, calculator.add(2, 2)) },
{ assertEquals(5, calculator.add(2, 3)) }
)
mg6maciej
05/31/2017, 8:16 PMjavaru
05/31/2017, 8:16 PMmg6maciej
05/31/2017, 8:16 PMfun assertAll(vararg executables: () -> Unit) {
Assertions.assertAll(
executables.map { Executable(it) }.stream()
)
}
javaru
05/31/2017, 8:19 PMExecutable
before the lambda works like a charm. Thanks. I'll vote for the feature requesting to simplify the syntax. Thanks for the assist!mg6maciej
05/31/2017, 8:21 PMassertAll
function to your test code similar to that one I'm using to get it now.javaru
05/31/2017, 8:22 PM