小编Jon*_*nas的帖子

收到 kotlin 错误“等待 60000 毫秒后,测试协程未完成”

我是测试新手,试图获取第二个流量值并断言它,当我逐个运行此测试时运行良好,但是当我运行整个测试时,第一个测试运行良好,其余测试给我超时错误。

错误 :

After waiting for 60000 ms, the test coroutine is not completing
kotlinx.coroutines.test.UncompletedCoroutinesError: After waiting for 60000 ms, the test coroutine is not completing
    at app//kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTestCoroutine$3$3.invokeSuspend(TestBuilders.kt:304)
    (Coroutine boundary)
Run Code Online (Sandbox Code Playgroud)
@OptIn(ExperimentalCoroutinesApi::class)
class HomeViewModelTest {

    private lateinit var viewModel: HomeViewModel
    private val testDispatcher = UnconfinedTestDispatcher()

    @Before
    fun setup() {
        viewModel = HomeViewModel(FakeOrderRepository())
        Dispatchers.setMain(testDispatcher)
    }

    @After
    fun tearDown() {
        Dispatchers.resetMain()
        testDispatcher.cancel()
    }

    @Test
    fun flowViewModelTesting1() = runTest {
        val result = viewModel.homeUiState.drop(1).first()
        assertThat(true).isTrue()
    }


    @Test
    fun flowViewModelTesting2() = runTest {
        val result …
Run Code Online (Sandbox Code Playgroud)

android kotlin kotlin-coroutines kotlin-flow

21
推荐指数
2
解决办法
1万
查看次数

将导航材质 ModalBottomSheetLayout 扩展到最大或自定义高度

我正在尝试实现https://google.github.io/accompanist/navigation-material/并且我想将模型表扩展到自定义高度或超过半个屏幕,但我不知道如何实现它

当前型号BottomSheet

在此输入图像描述

想要这样扩展

在此输入图像描述

android android-jetpack-compose jetpack-compose-accompanist

1
推荐指数
1
解决办法
3002
查看次数