@@ -19,7 +19,12 @@ package com.google.firebase.dataconnect.testutil
1919import androidx.test.ext.junit.runners.AndroidJUnit4
2020import com.google.firebase.dataconnect.ConnectorConfig
2121import com.google.firebase.util.nextAlphanumericString
22+ import io.kotest.property.Arb
2223import io.kotest.property.RandomSource
24+ import io.kotest.property.arbitrary.Codepoint
25+ import io.kotest.property.arbitrary.alphanumeric
26+ import io.kotest.property.arbitrary.arbitrary
27+ import io.kotest.property.arbitrary.string
2328import kotlin.random.Random
2429import org.junit.Rule
2530import org.junit.rules.TestName
@@ -40,6 +45,31 @@ abstract class DataConnectIntegrationTestBase {
4045
4146 val rs: RandomSource by randomSeedTestRule.rs
4247
48+ /* *
49+ * Generates and returns a string containing random alphanumeric characters, including the name of
50+ * the currently-running test as returned from [testName].
51+ *
52+ * @param string The [Arb] to use to generate the random string; if not specified, then an [Arb]
53+ * that generates strings of 20 alphanumeric characters is used.
54+ * @param prefix A prefix to include in the returned string; if null (the default) then no prefix
55+ * will be included.
56+ * @return a string containing random characters and incorporating the other information
57+ * identified above.
58+ */
59+ fun Arb.Companion.alphanumericString (
60+ string : Arb <String > = Arb .string(20, Codepoint .alphanumeric()),
61+ prefix : String? = null,
62+ ): Arb <String > = arbitrary {
63+ buildString {
64+ if (prefix != null ) {
65+ append(prefix)
66+ }
67+ append(testName)
68+ append(" _" )
69+ append(string.bind())
70+ }
71+ }
72+
4373 companion object {
4474 val testConnectorConfig: ConnectorConfig
4575 get() =
0 commit comments