Testing

Test coverage and how to run tests in Scanly v1.0.17.

Running tests

# Unit tests (no device required)
./gradlew.bat testDebugUnitTest

# Instrumented tests (device/emulator required)
./gradlew.bat connectedDebugAndroidTest

# Lint
./gradlew.bat lintDebug

Unit tests (app/src/test/)

50 test classes covering core logic, plus in-memory repository fakes under testing/:

AreaTest files
ML / geometryDocumentCornerQuadTest, DocumentQuadPolicyTest, DocumentGatePolicyTest, CornerRegressionDecoderTest, BookPageQuadAnalyzerTest, AutomaticDocumentModelSelectionPolicyTest, PerspectiveQuadMathTest, CropQuadEditorTest
ProcessingAdaptivePageFilterTuningTest, PageFilterPresetTest, PageFilterAdjustmentsTest
CameraCaptureStabilityTrackerTest, DocumentGateStabilityTrackerTest, StableCornerSelectorTest, CaptureFrameQualityAnalyzerTest, CameraOverlayMapperTest, CameraPermissionSupportTest, ScanSessionScreenTest
UI / layoutAdaptiveLayoutTest, PreviewImageSizerTest, ZoomableImageStateTest, OnboardingLayoutModeTest
FormattingStorageFormatterTest, DocumentPresentationFormatterTest, DocumentPreviewPathResolverTest
Domain modelsDocumentCornerModelTest, ExportDestinationTest, PageFilterPresetTest, PdfExportOptionsTest
Feature logicLibraryUiStateTest, DocumentDetailSelectionResolverTest, PageImagePreviewSelectionResolverTest, SuggestDocumentTitleUseCaseTest, ScanlyLaunchActionTest, LibraryCardPresentationTest, DocumentPageTilePresentationTest
Flow / use caseDocumentLibraryFlowTest, ScanSessionAndPageEditFlowTest, ExportArchiveAndClearDataFlowTest, ToolsSettingsAndLaunchActionFlowTest
UpdatesAppUpdateDialogCooldownTest, ReleaseMarkdownParserTest, AppVersionComparatorTest, GitHubAppUpdateRepositoryTest, PlayInAppUpdatePolicyTest
Backup/exportLibraryArchivePolicyTest, PdfPageLayoutResolverTest
Tools presentationPdfReaderPresentationTest, PdfToolPresentationTest, QrToolPresentationTest

Placement convention

Mirror the source package:

app/src/test/java/in/c1ph3rj/scanly/{matching/package}/YourTest.kt

Instrumented tests (app/src/androidTest/)

FileCoverage
ScanlyDeviceUiTest.ktReal MainActivity: onboarding → Home, Library / Tools / Settings chrome, QR generate preview
ScanlyDeviceUiRobot.ktShared Compose/UiAutomator helpers for the device UI suite
OnboardingScreenTest.ktCompose UI test for onboarding screen
OpenCvPageFilterProcessorTest.ktDevice-side OpenCV filter engine checks (flatten, color marks, preview/save parity)
ExampleInstrumentedTest.ktPackage name smoke test

Device UI tests use Android Test Orchestrator and clear app data between cases. Full run/install instructions: running-and-testing.md.

JVM flow tests (domain/usecase/)

These call shipped use cases with in-memory fakes (no device):

FileCoverage
DocumentLibraryFlowTestDocument/group lifecycle, library visibility, page reorder/delete
ScanSessionAndPageEditFlowTestScan add vs retake routes, import cap, crop/filter/adjust
ExportArchiveAndClearDataFlowTestPDF/ZIP export, backup restore Replace vs Merge, clear-all-data
ToolsSettingsAndLaunchActionFlowTestQR, PDF toolkit, prefs/onboarding, launch-action redirects

Coverage gaps

Still not covered on-device or with real I/O (prioritized):

  1. Persistence integration — Room migrations, repository round-trips
  2. Export end-to-end — PDF/ZIP bytes from the real exporter and save-to-destination
  3. Archive end-to-end — .scanly zip round-trip (JVM tests cover Replace vs Merge via in-memory fakes)
  4. Capture instrumented — Camera session on device (gate + multi-model path)
  5. Settings DataStore — preference round-trips against real DataStore (JVM tests cover use-case persistence against an in-memory settings store)

What to test when contributing

Change typeMinimum verification
Geometry / processing mathUnit test
ML policy (gate, quad, book, auto-select)Unit test for pure policy helpers
ViewModel state logicUnit test for resolvers/state
New use caseUnit test if non-trivial
UI layoutScreenshot or instrumented test for critical flows
Shell navigation / onboardingScanlyDeviceUiTest on a connected device
Room migrationManual test on device with old schema data
User-facing featureUpdate docs + manual device verification

View source on GitHub · Markdown