Skip to content

Commit

Permalink
Attempt at fixing flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
stigi committed Oct 7, 2024
1 parent 1ed976a commit 72e32d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
# run: ./gradlew build

- name: Test with Gradle Wrapper
run: ./gradlew testDebugUnitTest --tests "*test_notifyReadNotification_withDefaultStorePredicateAndDoesntExists_shouldRefresh"
run: ./gradlew test
# run: ./gradlew testDebugUnitTest --tests "*test_notifyReadNotification_withDefaultStorePredicateAndDoesntExists_shouldRefresh"

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
Expand Down
4 changes: 2 additions & 2 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ dependencies {

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation "io.mockk:mockk:1.12.2"
testImplementation "io.mockk:mockk-agent-jvm:1.12.2"
testImplementation "io.mockk:mockk:1.12.8"
testImplementation "io.mockk:mockk-agent-jvm:1.12.8"
testImplementation 'io.kotest:kotest-assertions-core-jvm:5.1.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ internal class NotificationStoreRealTimeTests {

@Test
fun test_notifyReadNotification_withDefaultStorePredicateAndDoesntExists_shouldRefresh() = runBlocking {

Check failure on line 223 in sdk/src/test/java/com/magicbell/sdk/feature/store/NotificationStoreRealTimeTests.kt

View workflow job for this annotation

GitHub Actions / JUnit Test Report

NotificationStoreRealTimeTests.test_notifyReadNotification_withDefaultStorePredicateAndDoesntExists_shouldRefresh()

java.lang.AssertionError: Verification failed: call 1 of 1: FetchStorePageInteractor(#33).invoke(any(), any(), any(), any())). One matching call found, but needs at least 2 and at most 2 calls Call: FetchStorePageInteractor(#33).invoke(StorePredicate(read=null, seen=null, archived=false, categories=[], topics=[]), com.magicbell.sdk.common.network.graphql.CursorPredicate@51f18e31, com.magicbell.sdk.common.query.UserQuery@60ed12e8, continuation {}) Stack trace: io.mockk.impl.InternalPlatform.captureStackTrace (InternalPlatform.kt:125) io.mockk.impl.stub.MockKStub.handleInvocation (MockKStub.kt:255) io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation (JvmMockFactoryHelper.kt:24) io.mockk.proxy.jvm.advice.Interceptor.call (Interceptor.kt:21) io.mockk.proxy.jvm.advice.BaseAdvice.handle (BaseAdvice.kt:42) io.mockk.proxy.jvm.advice.jvm.JvmMockKProxyInterceptor.interceptNoSuper (JvmMockKProxyInterceptor.java:45) com.magicbell.sdk.feature.store.interactor.FetchStorePageInteractor$Subclass0.invoke (-:-1) com.magicbell.sdk.feature.store.NotificationStore$fetch$2$1.invokeSuspend (NotificationStore.kt:363) kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33) kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136) java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635) java.lang.Thread.run (Thread.java:840)
Raw output
java.lang.AssertionError: Verification failed: call 1 of 1: FetchStorePageInteractor(#33).invoke(any(), any(), any(), any())). One matching call found, but needs at least 2 and at most 2 calls
Call: FetchStorePageInteractor(#33).invoke(StorePredicate(read=null, seen=null, archived=false, categories=[], topics=[]), com.magicbell.sdk.common.network.graphql.CursorPredicate@51f18e31, com.magicbell.sdk.common.query.UserQuery@60ed12e8, continuation {})
Stack trace:
                                               io.mockk.impl.InternalPlatform.captureStackTrace (InternalPlatform.kt:125)         
                                                 io.mockk.impl.stub.MockKStub.handleInvocation  (MockKStub.kt:255)                
               io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation        (JvmMockFactoryHelper.kt:24)      
                                        io.mockk.proxy.jvm.advice.Interceptor.call              (Interceptor.kt:21)               
                                         io.mockk.proxy.jvm.advice.BaseAdvice.handle            (BaseAdvice.kt:42)                
                       io.mockk.proxy.jvm.advice.jvm.JvmMockKProxyInterceptor.interceptNoSuper  (JvmMockKProxyInterceptor.java:45)
com.magicbell.sdk.feature.store.interactor.FetchStorePageInteractor$Subclass0.invoke            (-:-1)                            
                  com.magicbell.sdk.feature.store.NotificationStore$fetch$2$1.invokeSuspend     (NotificationStore.kt:363)        
                          kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith        (ContinuationImpl.kt:33)          
                                            kotlinx.coroutines.DispatchedTask.run               (DispatchedTask.kt:106)           
                                      java.util.concurrent.ThreadPoolExecutor.runWorker         (ThreadPoolExecutor.java:1136)    
                               java.util.concurrent.ThreadPoolExecutor$Worker.run               (ThreadPoolExecutor.java:635)     
                                                             java.lang.Thread.run               (Thread.java:840)                 
	at io.mockk.impl.recording.states.VerifyingState.failIfNotPassed(VerifyingState.kt:63)
	at io.mockk.impl.recording.states.VerifyingState.recordingDone(VerifyingState.kt:42)
	at io.mockk.impl.recording.CommonCallRecorder.done(CommonCallRecorder.kt:47)
	at io.mockk.impl.eval.RecordedBlockEvaluator.record(RecordedBlockEvaluator.kt:64)
	at io.mockk.impl.eval.VerifyBlockEvaluator.verify(VerifyBlockEvaluator.kt:30)
	at io.mockk.MockKDsl.internalCoVerify(API.kt:144)
	at io.mockk.MockKKt.coVerify(MockK.kt:175)
	at io.mockk.MockKKt.coVerify$default(MockK.kt:166)
	at com.magicbell.sdk.feature.store.NotificationStoreRealTimeTests$test_notifyReadNotification_withDefaultStorePredicateAndDoesntExists_shouldRefresh$1.invokeSuspend(NotificationStoreRealTimeTests.kt:244)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at com.magicbell.sdk.feature.store.NotificationStoreRealTimeTests.test_notifyReadNotification_withDefaultStorePredicateAndDoesntExists_shouldRefresh(NotificationStoreRealTimeTests.kt:223)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:119)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:94)
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:89)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
// FLAKY TEST?

delay(1000)

// GIVEN
val predicate = StorePredicate()
val storePage = givenPageStore(predicate, defaultEdgeArraySize)
Expand All @@ -234,13 +238,20 @@ internal class NotificationStoreRealTimeTests {
val initialCounter = InitialNotificationStoreCounts(store)
storeRealTime.processMessage(RealTimeEventMock.ReadNotification("Not exists"))

// DEBUG

// THEN
coVerify(exactly = 2) { fetchStorePageInteractor.invoke(any(), any(), any()) }
store.size.shouldBeExactly(defaultEdgeArraySize)
store.totalCount.shouldBeExactly(initialCounter.totalCount)
storePage.edges.mapIndexed { index, edge ->
store[index].id.shouldBe(edge.node.id)
}

// FLAKY TEST?

delay(1000)

Unit
}

Expand Down

0 comments on commit 72e32d1

Please sign in to comment.