naver / fixture-monkey

Let Fixture Monkey generate test instances including edge cases automatically
https://naver.github.io/fixture-monkey
Apache License 2.0
560 stars 89 forks source link

Implement InnerSpec Kotlin DSL #981

Open seongahjo opened 4 months ago

seongahjo commented 4 months ago

Describe the feature you request

InnerSpec now shadow the lambda parameter it if you use the nested InnerSpec.

class CustomObject(val value: String)

val actual = SUT.giveMeBuilder<Map<String, CustomObject>>()
          .setInner {
             it.size(1)
                    .entry("key") { v ->
                        v.property("value", "expected")
                    }
          }
          .sample()

You should specify the parameter as v if you want to customize the value of Map. It is better to use Kotlin DSL for InnerSpec like below.

val actual = SUT.giveMeBuilder<Map<String, CustomObject>>()
          .setInner {
               size(1)
                entry("key") {
                        property("value", "expected")
                    }
          }
          .sample()

InstantiationDsl is a good reference.

   val actual = SUT.giveMeBuilder<Foo>()
            .instantiateBy {
                constructor<Foo> {
                    parameter<String>()
                    parameter<Int>()
                }
            }
            .sample()
            .bar

        then(actual).isNotNull
eunbileeme commented 4 months ago

Can I contribute this?

seongahjo commented 4 months ago

@eunbileeme Sure! Let me know if you have any questions.

seongahjo commented 2 months ago

@eunbileeme Hello, are there any updates?

eunbileeme commented 2 months ago

Hello. Sorry, I was already mistaken that someone else solved it.

Is there a set period for the issue to close?

seongahjo commented 2 months ago

@eunbileeme No, no fixed deadline. But let me know if you do not have time to resolve this issue for other contributors. 😄

eunbileeme commented 2 months ago

@seongahjo Checked it. I will commit as soon as possible or share the schedule.

Once again, I'm sorry for the late confirmation. 😢