huehnerlady
08/07/2020, 5:49 AMSylvain Moindron
08/07/2020, 6:07 AMhuehnerlady
08/07/2020, 6:12 AMMilan Hruban
08/07/2020, 8:17 AMhuehnerlady
08/07/2020, 8:35 AMhuehnerlady
08/07/2020, 9:10 AMMilan Hruban
08/07/2020, 9:19 AMhuehnerlady
08/07/2020, 9:57 AMclass TestSuperClass {
data class SomeTestClass(val property1: String?, val property2: String?)
}
Then I try to create a function for tests in a file “Extentions.kt” looking like this:
import de.europace.pm.edge.api.legacy.TestSuperClass.SomeTestClass
inline fun SomeTestClass(property1: String? = null): SomeTestClass = SomeTestClass(property1 = property1, property2 = null)
When I then try to call that funktion in my test though, it cannot be found and I get the compile errors
No value passed for parameter 'property1'
No value passed for parameter 'property2'
When The data class is outside the TestSuperClass
, it works as expected with the overloaded constructor.
So is that a limitation or is there a tweak I have to add to my extention function for it to work?
I could totally understand if that is not possible, as it seems odd to generate the data classes inside the other class, but I cannot change that yunfortunately as I am too happy for the other way it works with graphql to change it bcause I do not like the way to write tests 😅Milan Hruban
08/07/2020, 10:45 AMinline fun SomeTestClass(property1: String? = null): TestSuperClass.SomeTestClass = TestSuperClass.SomeTestClass(property1 = property1, property2 = null)
thanksforallthefish
08/07/2020, 11:28 AMval myDataClass = mockk<DataClass>{
every { property } returns "something"
} //for instance, with <http://mockk.io|mockk.io>
this way it is also clear which of the values are actually used in which specific use casehuehnerlady
08/10/2020, 6:02 AMMatteo Mirk
08/25/2020, 6:02 AMIf I fill one value in and then add some data to the generated class, the parameter order might shift and then it is a pain to find out in which of the 51 positions I need to add the value.this is the exactly one of the problems that named arguments were meant solve