// FILE: docs/testing.md
Unit tests live in src/test/ inside each module. Run all at once or per-module:
./gradlew testDebugUnitTest
./gradlew :feature:ar:testDebugUnitTest
./gradlew :core:data:testDebugUnitTest| File | Module | Covers |
|---|---|---|
DualAnalyzerTest |
:feature:ar |
SLAM callback, light throttle, luminosity path |
ArViewModelTest |
:feature:ar |
Session management, flashlight, GPS, keyframe capture |
EditorViewModelTest |
:feature:editor |
Layer operations, bitmap dimensions, undo/redo |
ProjectManagerTest |
:core:data |
getProjectList, deleteProject, getMapPath, importProjectFromUri failure paths |
Note: Relocalization and teleological progress tracking run entirely in the C++ layer (MobileGS::relocThreadFunc for background PnP snap-back, MobileGS::tryUpdateFingerprint for painting-progress) to eliminate JVM overhead. As a result, they are verified visually on-device rather than via JVM unit tests.
Android Log on JVM — throws RuntimeException unless mocked:
mockkStatic(Log::class)
every { Log.e(any(), any()) } returns 0
every { Log.e(any(), any(), any()) } returns 0
every { Log.i(any(), any()) } returns 0Kotlin objects (singletons):
mockkObject(ImageProcessingUtils)
mockkObject(BitmapUtils)
coEvery { BitmapUtils.getBitmapDimensions(any()) } returns Pair(100, 100)OpenCV Mat — Mat() calls native code; instantiating it on JVM causes UnsatisfiedLinkError:
val mat = mockk<Mat>(relaxed = true)
every { mat.get(any<Int>(), any<Int>()) } returns doubleArrayOf(1.0)ARCore Session — cannot be instantiated on JVM. ARCore session tests belong in instrumented (src/androidTest/) tests, not JVM unit tests.
CameraManager (flashlight):
val cameraManager = mockk<CameraManager>(relaxed = true)
every { context.getSystemService(Context.CAMERA_SERVICE) } returns cameraManagerNo automated C++ test runner is integrated. Use visual verification:
- Enable
DEBUG_COLORSinMobileGS.h. - Scan a corner. If the corner looks like a rainbow, the normals are wrong.
- Location:
src/androidTest/in each module. - Scope:
AzNavRailinteractions. - Note: Mock
ArRendererwhen writing Compose tests — ARCore cannot be instantiated in UI tests.
Before a release:
- Build release APK.
- Go to a physical brick wall.
- Scan it — confirm
TRACKINGchip turns green in the AR viewport. - Project an image.
- Walk 5 metres away and return.
- Pass Condition: The image is still on the wall within < 1cm of drift.