Robert Menke
08/13/2019, 8:34 PMigor.wojda
08/13/2019, 9:48 PM5
is cooler that number 4
🤔?jmfayard
09/04/2019, 9:45 AM@VisibleForTesting
exists in pure Kotlin?
On Android we have android.support.annotation.VisibleForTesting
to change the visibility of properties and methods for unit tests.Marcin Wiśniewski
09/16/2019, 6:31 PMLou Morda
09/17/2019, 10:48 PMrkeazor
10/01/2019, 12:37 AMrkeazor
10/09/2019, 12:46 PMMarc Knaup
10/18/2019, 2:51 PMDeprecationLevel.HIDDEN
? 😄niklas
10/22/2019, 3:32 PMsbt testQuick
does but in Kotlin + JUnit5 (with Gradle)?ubu
11/06/2019, 11:40 AM@Test
fun `should emit one account, then two accounts without images`() = runBlockingTest {
val firstAccount = Account(
id = MockDataFactory.randomUuid(),
name = MockDataFactory.randomString(),
avatar = Image(
id = MockDataFactory.randomUuid(),
sizes = listOf(Image.Size.SMALL)
)
)
val secondAccount = Account(
id = MockDataFactory.randomUuid(),
name = MockDataFactory.randomString(),
avatar = Image(
id = MockDataFactory.randomUuid(),
sizes = listOf(Image.Size.SMALL)
)
)
val accounts = flow {
emit(firstAccount)
delay(100)
emit(secondAccount)
}
val blob = ByteArray(0)
val response = Either.Right(blob)
observeAccounts.stub {
onBlocking { build() } doReturn accounts
}
loadImage.stub {
onBlocking { invoke(any(), any(), any()) } doAnswer { answer ->
answer.getArgument<(Either<Throwable, ByteArray>) -> Unit>(2)(response)
}
}
vm = buildViewModel()
vm.state.observeForTesting {
advanceTimeBy(1000)
assertEquals(
expected = listOf(
SelectAccountView.AccountView(
id = firstAccount.id,
name = firstAccount.name,
image = blob
),
SelectAccountView.AccountView(
id = secondAccount.id,
name = secondAccount.name,
image = blob
)
),
actual = vm.state.value
)
}
vm.viewModelScope.cancel()
}
Why would advanceTimeBy
not work? Test fails: I receive only the first emission containing the first account. I wonder how to test several live data emissions, each being delayed by some interval.ursus
12/04/2019, 11:06 AMBrendan Weinstein
01/08/2020, 8:46 PMNoSuchMethodError
.
java.lang.NoSuchMethodError: No static method runBlocking$default(Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/lang/Object; in class Lkotlinx/coroutines/BuildersKt; or its super classes (declaration of 'kotlinx.coroutines.BuildersKt' appears in /data/app/build-acBhKAw8srVGmPVxba9HCw==/base.apk!classes2.dex)
I have defined rules for testProguardFiles
to do nothing and I have redeclared the coroutines dependency with androidTestImplementation
. Is there a way to force the test code to use a separate classpath for coroutines? Or what's the recommended way to resolve?tenprint
01/10/2020, 1:21 PMManuel Lorenzo
01/13/2020, 9:26 AMAntoine Gagnon
02/24/2020, 3:26 PMclass MathTest {
@Test
fun test_should_fail_function() {
assert(2.0.pow(24) == 2.0)
}
}
In my build.gradle I have these imports:
// Android Instrumentation
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
androidTestImplementation "de.mannodermaus.junit5:android-test-core:1.0.0"
androidTestRuntimeOnly "de.mannodermaus.junit5:android-test-runner:1.0.0"
Any idea what could be making all of them succeed ?tim
03/11/2020, 12:15 PMtylerwilson
03/19/2020, 2:48 PMGilberto Diaz
03/25/2020, 5:31 PMclass DateUtils {
fun LocalDateTime.setTimeZone(targetTimeZone: String): LocalDateTime {
return ZonedDateTime.of(
this,
ZoneId.of(targetTimeZone)
).toLocalDateTime()
}
}
@Test
fun `It should set time zone`() {
val msgDateStr = "2020-03-07T11:55:00"
val format = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")
al currDate = LocalDateTime.parse(msgDateStr, format)
assertEquals("2020-03-07T11:55-05:00[America/New_York]", DateUtils.setTimeZone(currDate, "America/NewYork"))
}
DateUtils.setTimeZome(...) // I get a Unresolved reference: setTimeZone
Antoine Gagnon
04/16/2020, 3:06 PMRita Curado
04/17/2020, 9:07 AMclass Api(s: String) {
private val name = s
}
I am doing this:
_val apiMock = mock_<Api> { … }
How can I pass the `s`argument the class needs?
Thanks in advanceGilberto Diaz
04/17/2020, 5:13 PMif() {} else {}
statement? How I can do that?ursus
04/19/2020, 6:15 AMGilberto Diaz
04/22/2020, 5:56 PMrobstoll
04/25/2020, 9:54 PMpardom
04/30/2020, 3:02 PMkotlin.test
) similar to the way spekframework and kotest do, rather than writing n
variants for the same test.Antoine Gagnon
05/25/2020, 2:49 PMRodrigo Silva
06/01/2020, 10:33 PMAlex Kuznetsov
06/10/2020, 10:26 PMSam
06/12/2020, 9:22 AMSmall tests are unit tests that validate your app's behavior one class at a time.
Medium tests are integration tests that validate either interactions between levels of the stack within a module, or interactions between related modules.
Large tests are end-to-end tests that validate user journeys spanning multiple modules of your app.
Gaurav
07/14/2020, 1:54 AMGaurav
07/14/2020, 1:54 AMdazza5000
07/15/2020, 10:58 PMGaurav
07/16/2020, 2:16 AM