Colton Idle
04/22/2023, 11:18 PMChris Lee
04/22/2023, 11:28 PMColton Idle
04/22/2023, 11:36 PM@Test
fun `test prod`() = runBlocking {
val apolloClient = ApolloClient.Builder()
.serverUrl("my prod url")
.build()
val result = ..
assert(result.isSuccess)
}
and
@Test
fun `test staging`() = runBlocking {
val apolloClient = ApolloClient.Builder()
.serverUrl("my staging url")
.build()
val result = ..
assert(result.isSuccess)
}
so I just would like to combine those two into 1Chris Lee
04/22/2023, 11:39 PMephemient
04/22/2023, 11:41 PM@RunWith(Parameterized::class)
class MyTest(val serverUrl: String) {
@Test
fun test() = runBlocking {
val apolloClient = ApolloClient.Builder()
.serverUrl(serverUrl)
.build()
}
companion object {
@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun data(): Iterable<Array<*>> = listOf(
arrayOf("my prod url"),
arrayOf("my staging url"),
)
}
}
@ParameterizedTest
@ValueSource(strings = ["my prod url", "my staging url"]
fun test(serverUrl: String) {
// ...
is more concise and more flexible, if you can migrateColton Idle
04/22/2023, 11:54 PMephemient
04/22/2023, 11:55 PMColton Idle
04/23/2023, 12:00 AM@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun data(): Iterable<Any> = listOf(
"my prod url",
"my staging url",
)
ephemient
04/23/2023, 1:05 AMclass MyTest(ignoredName: String, val serverUrl: String) {
companion object {
@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun data(): Iterable<Array<*>> = listOf(
arrayOf("prod", "my prod url"),
arrayOf("staging", "my staging url"),
)
the {0}
makes it shows up as [prod]
or [staging]
in the test reporttoString
then it doesn't matter of course, and if you don't mind the default index-based naming, then I guess you don't need to bother eitherColton Idle
04/23/2023, 1:09 AMeygraber
04/23/2023, 1:41 AMephemient
04/23/2023, 1:42 AMColton Idle
04/24/2023, 4:13 AMkqr
04/24/2023, 6:35 AMephemient
04/24/2023, 10:21 PMplugins {
`jvm-test-suite`
}
testing {
suites {
val integrationTest by registering(JvmTestSuite::class) {
useJUnit()
targets.all {
testTask.configure {
systemProperty("serverUrl", project.property("serverUrl"))
}
}
}
}
}
with a val serverUrl: String = System.getProperty("serverUrl")
lookup in src/integrationTest/kotlin/*
and running with ./gradlew integrationTest -PserverUrl='my staging url'
or -PserverUrl='my prod url'
, etc.val integrationTest by sourceSets.creating
dependencies {
integrationTest.implementationConfigurationName(kotlin("test-junit"))
}
testing {
suites {
val stagingIntegrationTest by registering(JvmTestSuite::class) {
dependencies {
implementation(files(integrationTest.runtimeClasspath))
}
useJUnit()
targets.all {
testTask.configure {
systemProperty("serverUrl", "my staging url")
testClassesDirs = files(testClassesDirs, integrationTest.output.classesDirs)
}
}
}
val prodIntegrationTest by registering(JvmTestSuite::class) {
dependencies {
implementation(files(integrationTest.runtimeClasspath))
}
useJUnit()
targets.all {
testTask.configure {
systemProperty("serverUrl", "my prod url")
testClassesDirs = files(testClassesDirs, integrationTest.output.classesDirs)
}
}
}
}
}
if you would rather have separate tests executions for different pre-defined environment using the same test classesColton Idle
04/25/2023, 12:47 PMdewildte
04/26/2023, 8:23 PMeygraber
04/26/2023, 8:47 PMChris Lee
04/26/2023, 8:49 PMephemient
04/26/2023, 9:06 PMjvm-test-suite
makes easyColton Idle
04/27/2023, 12:08 AMephemient
04/27/2023, 7:53 AMColton Idle
04/27/2023, 12:21 PMeygraber
04/27/2023, 1:56 PMdewildte
04/27/2023, 7:24 PMYeah. I know that its sorta e2e (its not really like UI e2e test, but testing that a network call works and is deserialized properly catches like 90% of our bugs). so i dont really have any other thoughts on how to structure this. open to ideas.Would a more simple test that proves you can deserialize the expected JSON suffice? You could store the JSON (and variants of it even) in a file and then run it against the test. If it is just deserialization that is needed then you do not need to connect to the real server for that. A simple test like this could be used to prove you can handle proposed responses from an endpoint before the endpoint is even deployed and operational.
ephemient
04/27/2023, 10:08 PMdewildte
04/27/2023, 10:39 PMChris Lee
04/27/2023, 10:39 PMdewildte
04/27/2023, 10:43 PM• Two or more subsystems have different semantics, but still need to communicate.
eygraber
04/27/2023, 10:46 PMChris Lee
04/27/2023, 10:47 PMdewildte
04/27/2023, 10:48 PMChris Lee
04/27/2023, 10:49 PMdewildte
04/27/2023, 10:49 PMephemient
04/27/2023, 10:49 PMeygraber
04/27/2023, 10:54 PMChris Lee
04/27/2023, 10:55 PMColton Idle
04/28/2023, 6:23 AMeygraber
04/28/2023, 2:53 PMColton Idle
04/28/2023, 3:09 PM