Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
13 views

How to get unit test code coverage of Android kotlin project?

I have a Andorid kotlin project. I want to get the code coverage of the unit test using some script as it needs to be included in CI/CD pipeline. How can I achieve this? Thanks.
Abhiroop Nandi Ray's user avatar
0 votes
1 answer
14 views

java.lang.RuntimeException: Method getMainLooper in android.os.Looper not mocked

I got this error when I use JUnit5 for Unit testing: java.lang.RuntimeException: Method getMainLooper in android.os.Looper not mocked. at android.os.Looper.getMainLooper(Looper.java) at androidx.arch....
Mona Baharlou's user avatar
0 votes
0 answers
22 views

ParameterizedTest JUNIT5 with suspend functions

I'm trying to clean a little bit my code and when testing my datasource I'm repeating a lot the test that returns connection and service error, and I'd like to have a bunch of code that tests ...
StuartDTO's user avatar
  • 891
0 votes
0 answers
22 views

Android: Unit-Test (GPS) LocationListener using Robolectric

I want to test the location listener. Following code: @RequiresPermission(anyOf = [permission.ACCESS_FINE_LOCATION]) override fun getCurrentLocationFlow(): Flow<GeoLocation> = callbackFlow { ...
Franklin84's user avatar
0 votes
0 answers
24 views

MockK - Stubbed method persists even after class mock was cleared

I am trying to stub a class method twice to test both happy and error path, but for some reason MockK is unable to clear stubbed methods per test. For convenience I know I can use returnsMany or ...
hbjosemaria's user avatar
0 votes
0 answers
214 views

Kotlin unit test suspend function "android.os.Looper.getMainLooper()" is null

I tried to test a suspend function got the error: Cannot invoke "android.os.Looper.getThread()" because the return value of "android.os.Looper.getMainLooper()" is null class ...
William Hu's user avatar
  • 15.9k
1 vote
2 answers
123 views

Testing Dispatcher IO and ViewModelScope in Unit Tests

I'm trying to test some code in my viewmodel. I'm trying to make two network calls with dispatcher async, but haven't figured out how to test. This is a simplified example of what I'm essentially ...
keyboard_user's user avatar
0 votes
0 answers
22 views

Unit testing class with flow collection in init

How can I best go about unit testing flows that are collected in a class's init function? The only solution I've come up with so far requires hard-coded delays. Consider a sample implementation of a ...
Henrik Klev's user avatar
0 votes
0 answers
12 views

How to do unit test on SoLoader.loadLibrary

I have a couple of native library that I use soLoader to load during run-time, but the dependency kept getting break during the development. Is it possible to write a unit test against SoLoader....
user2386301's user avatar
0 votes
1 answer
46 views

How to set HttpServletRequest headers when unit testing with GraphQlTester in kotlin?

I'm working on a Spring Boot project using Kotlin and GraphQL. For unit testing, I'm using GraphQlTester from org.springframework.graphql.test.tester.GraphQlTester. I need to pass headers to the ...
chathura's user avatar
0 votes
1 answer
48 views

Best practice for testing the initial state of a ViewMode with Turbine

I have a simple ViewModel with a state that keeps some data. State is initialized in the init function of my ViewModel: ViewModelState.kt data class ViewModelState( val myInfo: String = "&...
Nadi-Shuddhi's user avatar
1 vote
1 answer
35 views

Test of a view model's coroutine never finishes

data class TimerInstance( val isEnabled: Boolean, val timeElapsed: Long, ) class TimerViewModel(val dispatcher: CoroutineDispatcher = Dispatchers.Default) : ViewModel() { private val ...
HukeLau_DABA's user avatar
  • 2,486
0 votes
1 answer
19 views

how can i take access to test method like AbstractClass.InnerClass.fun

I'm trying to write unit test for Abstract Class Realization and I need to write test for method with path Class.InnerClass.fun. example InClass.b2: package com.example.kotlin_spring abstract class ...
Zzz Zzz's user avatar
0 votes
1 answer
32 views

JUnit Testing Multiple Values Against Same Function Best Practice

Say I have various input strings that are passed into the same function and returns output strings that are compared against their expected results. For example, periods should be transformed to ...
BobDidley's user avatar
  • 123
0 votes
0 answers
26 views

How I can test location service, and it's permissions with junit?

Is it possible to write to write instrumental tests and later on for location permissions? I'm relatively new to testing topic, and I haven't found much examples that could possibly help me with it.
SmierdzoncaRobotaEhhh's user avatar

15 30 50 per page
1
2 3 4 5
69