You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if you could write something like this in kotlin when working with junit5
@TestFactory
fun`dynamic tests returned as Kotlin sequence`() = generateSequence(0) { it +2 }
.map { dynamicTest("$it should be even") { assertTrue(it %2==0) } }
.take(10)
Now you have to add .toIterable() as extra line to make it work with junit5.
Deliverables
Adding support for converting iterator providing classes to a stream in org.junit.platform.commons.util.CollectionUtils.
Adding support for converting spliterator prodiving classes to a stream in org.junit.platform.commons.util.CollectionUtils.
The kotlin Sequence class is an example of an iterator providing class. But it is not an Iterable. That's why it does not work as returntype for for example @testfactory annotated methods at the moment.
A benefit of adding this at this low level is that, kotlin Sequences, or any other Iterator or Spliterator providing class can now also be used in other junit5 methods where an object from an annotated method needs to be converted to a stream.
I would like to contribute to junit5 and make a pull request for this branch but I don't have push permission yet for a feature branch in the junit5 project.
Could you please be so kind to take a look at the suggestion I provided?
Thanks in advance! I'm awaiting your response :)
The text was updated successfully, but these errors were encountered:
hanszt
changed the title
Add kotlin sequence support for @testfactory methods
Add kotlin Sequence support for @TestFactory annotated methods
Jul 2, 2023
It would be nice if you could write something like this in kotlin when working with junit5
Now you have to add
.toIterable()
as extra line to make it work with junit5.Deliverables
The kotlin Sequence class is an example of an iterator providing class. But it is not an Iterable. That's why it does not work as returntype for for example @testfactory annotated methods at the moment.
A benefit of adding this at this low level is that, kotlin Sequences, or any other Iterator or Spliterator providing class can now also be used in other junit5 methods where an object from an annotated method needs to be converted to a stream.
I have an implementation for it ready. see:
Suggestion
All tests still pass.
I would like to contribute to junit5 and make a pull request for this branch but I don't have push permission yet for a feature branch in the junit5 project.
Could you please be so kind to take a look at the suggestion I provided?
Thanks in advance! I'm awaiting your response :)
The text was updated successfully, but these errors were encountered: