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
Any tips/suggestions for getting null as a value? I know JSR won't allow null to be passed in because it's not a constant but is there any clean way of doing it besides generating my own TestParameterValuesProvider for every parameter that needs to support null?
// Doesn't work
@Test
fun someTest(@TestParameter(value = [null, "", "foo"]) param: String) {
...
}
// Ugly bc you'd have to define the provider for every String argument in every test method
@Test
fun someTest(@TestParameter(valuesProvider = FooProvider::class) param: String) {
...
}
class FooProvider : TestParameter.TestParameterValuesProvider {
override fun provideValues(): MutableList<String?> {
return mutableListOf(null, "", "foo")
}
}
The text was updated successfully, but these errors were encountered:
At the moment, your workaround seems to be the best solution for getting a null value, but I agree it's not ideal.
The following change would make it a lot easier to test for null values:
@Test
fun someTest(@TestParameter(value = ["null", "", "foo"]) param: String) {
// "null" wouldn't be interpreted as String but as null value
...
}
I've implemented this and I'm now re-running all Google tests to see if any existing code is relying on a "null" string being "null". If this turns out to work, I'll push it onto a new release.
Any tips/suggestions for getting null as a value? I know JSR won't allow null to be passed in because it's not a constant but is there any clean way of doing it besides generating my own TestParameterValuesProvider for every parameter that needs to support null?
The text was updated successfully, but these errors were encountered: