arekolek
07/16/2020, 10:36 AMwhen (action) {
// ...
}.exhaustive
where
val <T> T.exhaustive: T get() = this
to let the compiler know there is no else
branch neededAbhishek Bansal
07/16/2020, 12:57 PMfun groupByWeek(listItems: List<Item>, dateUtils: DateUtils): Map<Int, MutableList<Item>> {
val dateResponseMap = mutableMapOf<Int, MutableList<Item>>()
listItems.forEach { response ->
val date = dateUtils.getWeekOfCurrentYear(response.time)
date?.let {
if (!dateResponseMap.containsKey(date)) {
dateResponseMap[date] = mutableListOf()
}
dateResponseMap[date]?.add(response)
}
}
return dateResponseMap
}
Question here is to mock or not to mock DateUtils
class. DateUtils
is our custom class which is already Unit Tested. Not mocking it is not ideal but it saves a lot of trouble (note the usage of dateUtils.getWeekOfCurrentYear()
inside loop). listItems
here are coming from a fake repository. response.time
is long
timestamp.
Is there a better(more testable) way of writing this method?spand
09/03/2020, 12:21 PMtestImplementation project(':hltv-dataaccess').sourceSets.test.output
• Crazy stuff like: https://vkuzel.com/shared-test-sources-in-gradle-multi-module-project
• https://docs.gradle.org/5.6/userguide/java_testing.html#sec:java_test_fixtures Anyone used this with Kotlin?
• Other ?
I do not find any of the above options very appealing. Has anyone found a good solution ? (and why is it good)Davide Giuseppe Farella
09/20/2020, 6:46 AMjava.lang.NoSuchMethodError: database.movies.Movie.getTmdbId-8MyLogM()I
literally for every field which type is inline class.
That happens only in my JUnit tests, neither on running app, nor on CIsteamstreet
09/25/2020, 5:00 PMkevin.cianfarini
10/01/2020, 3:11 PM@RunWith(Parameterized::class)
?tylerwilson
10/06/2020, 4:09 PMTwoClocks
10/28/2020, 6:07 PMManuel Lorenzo
11/15/2020, 8:22 PMpoohbar
12/16/2020, 9:23 PMExpected true but got false
123
12/18/2020, 9:35 PMSimon Lin
01/05/2021, 8:50 AM// In android ViewModel
val user = MutableLiveData<User>()
fun loadUser() {
viewModelScope.launch {
user.value = userRepository.getUser()
}
}
Do I need to write a test for loadUser
? or it only show in a tutorial?Simon Lin
01/07/2021, 9:53 AMinit block
?
the sample:
class Foo() {
init {
loadData()
}
private fun loadData() {
repository.getData()
}
}
And this is what I done. Is it correct?
class FooTest {
private val foo by lazy { Foo() }
@Test
fun `test foo init block`() {
foo // access foo to create an instance by Lazy
coVerify(exactly = 1) { repository.getData() }
}
}
darkmoon_uk
01/15/2021, 7:52 AMval commonTest by getting {
dependencies {
api(Dependencies.KotlinTest.COMMON)
api(Dependencies.KotlinTest.ANNOTATIONS)
api("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.2") //This isn't resolved
}
}
Trying to resolve this gets the error in the thread - it looks like there's just no version of kotlinx-coroutines-test
for ios_x64
- is this a known limitation, packaging problem or... ?ursus
02/01/2021, 11:22 PMursus
02/03/2021, 3:28 AM@Test testSaveSubscribers() {
val queries = SubscriberQueries(JdbcDriver)
queries.insertAll( .. seed with some data) <--- Is this okay? seeding a dependency?
val dao = SubscriberDao(queries)
dao.saveSubscribers(listOf( ... ))
assertThat(dao.allSubscribers()).isEqualTo(...) <---- This? What if allXyz() won't be part of public api?
assertThat(queries.selectAll()).isEqualTo(...) <---- Or this when allXyz() is not available? Isn't asserting on a dependency weird?
}
Siva
02/05/2021, 8:39 PMursus
02/26/2021, 5:16 AMSimonT
03/04/2021, 9:48 PMursus
03/09/2021, 12:21 AMrobstoll
04/06/2021, 12:00 PMexpect(path).toBeADirectory()
vs. expect(path).toBeDirectory()
robstoll
04/20/2021, 8:09 PMlistOf(..).forEach { test("case $x") ... }
?Brendan Campbell-hartzell
05/07/2021, 6:30 PMJosé González Gómez
05/17/2021, 1:11 PM@Test
. I'm used to other test frameworks which give you a lot of freedom regarding test organization, for example Kotest provides several testing styles. So,
• Is there any recommended way to organize tests using kotlin.test? Or
• Is there any way to use another runner/framework which gives you more freedom regarding test organization in a multiplatform project?Chris Jobling
05/21/2021, 3:37 PMSam
07/17/2021, 4:44 PMEric Ampire [MOD]
08/15/2021, 5:33 PMJavier
09/17/2021, 3:03 PMankushg
10/05/2021, 10:31 PMkotlin.test
issue. Or maybe it's multiple issues combined 😵
• when clicking the gutter icon, IntelliJ is generating a --tests
filter that doesn't work
• I can manually change the --tests
filter to one that does work in IntelliJ by changing the nested-class separator from .
to $
• --tests
filter works when running via ./gradlew
--tests
filter to work when running via ./gradlew
when using single-quotes instead of double-quotes
Here's some context: https://youtrack.jetbrains.com/issue/KTIJ-10168#focus=Comments-27-5256146.0-0Carter
10/29/2021, 2:32 PMsettings.gradle.kts:
pluginManagement {
plugins {
id("org.jetbrains.kotlinx.kover") version ("0.3.0") apply (false)
}
}
submodule/build.gradle.kts:
plugins {
id("org.jetbrains.kotlinx.kover")
}
The build fails with a set of odd exceptions, which I’ll include in a thread.
Does anyone have Kover working yet?