whoami
Lucas Jenß
cat /etc/motd
The Coding Journal ツ — Notes taken on an epic coding journey. Technical solutions, debugging notes, and practical guides from the trenches of software development.
ls -la ~/languages/
- drwxr-xr-x
- ▶ PHP
- ▶ Ruby
- ▶ Scala
- ▶ C#
- ▶ JavaScript
- ▶ Objective-C
- ▶ Shell Scripting
ls -la ~/toolchain/
- drwxr-xr-x
- ▶ Typo3
- ▶ Akka
- ▶ Capistrano
- ▶ Git
- ▶ MAMP
- ▶ Adobe Illustrator
- ▶ NSTrackingArea (Cocoa)
uname -a
- drwxr-xr-x
- ▶ Mac OS X
- ▶ Unix
Faster UI testing with Android emulator snapshots
Using Android emulator snapshots to speed up UI testing workflows can remove much of the dead time around a UI suite. Instead of cold-booting a virtual device, waiting for Android services and recreating a predictable home screen for every run, the emulator can resume from a named state. The saving applies mainly to startup and setup; Espresso or UI Automator assertions still take as long as the code under test requires.
The benefit depends on discipline. A restored image can carry old permissions, cached records, an authenticated session or a screen caught mid-transition. A snapshot is therefore not a substitute for test isolation. It is a reusable fixture whose contents, creation point and reset rules should be documented so it produces consistent starting conditions on a laptop and in continuous integration.
Why snapshots change the testing loop
A cold boot exposes every startup cost: loading the system image, starting services, granting default permissions, unlocking the screen and waiting for package management to settle. UI automation often spends more time reaching its first assertion than exercising the screen. A restored state moves that setup work into a controlled earlier step.
Quick Boot is the emulator’s automatic snapshot mechanism, saving a resumable state when a virtual device shuts down. Named snapshots apply the same idea with explicit control over when a baseline is saved and loaded. Support depends on the emulator build and system image, so check the commands on the pinned CI image rather than assuming every AVD supports restoration.
For teams across Sydney, Melbourne and Brisbane, faster restores fit around a normal workday. A developer can prepare a test device between meetings instead of watching a cold boot while waiting at a station or for café Wi-Fi. The feedback loop gets shorter without changing what the test asserts.
Build a trustworthy baseline
Start with one pinned AVD rather than a collection of subtly different images. Pin the emulator revision, API level, system image and hardware profile in the same place as the app build. Include Google APIs only when the product needs them, because extra services add startup time and failure modes.
Readiness is more than seeing a device in adb devices. Poll sys.boot_completed and device_provisioned, then confirm the package manager can resolve an activity before installing anything:
adb wait-for-device
adb shell getprop sys.boot_completed
adb shell settings get global device_provisioned
The script should wait for expected values rather than merely print them. Disable window, transition and animator scales in the baseline so timing-sensitive gestures produce less noise.
Choose a baseline matching the suite’s assumptions. Usually, save before installing the app under test, then restore and install the exact APK. If a test needs seeded data, generate it from a committed fixture. Put locale, animation and permission settings in shared setup code so a snapshot does not hide test differences.
Save, restore and verify emulator snapshots
When the emulator is fully booted and idle, standard ADB console commands expose the snapshot controls:
adb emu avd snapshot list
adb emu avd snapshot save ui-clean
adb emu avd snapshot load ui-clean
These commands operate on the currently running AVD. If snapshot list is unavailable, that emulator and system-image combination does not support the workflow in the same way.
Save only after disk writes have settled and no test, synchronisation process or download is active. Name the image according to its purpose, such as ui-clean, and record the emulator and application versions in the test documentation. A snapshot containing live sockets or half-written databases is harder to reproduce than a fresh boot.
Treat the first restore as a deliberately destructive test. Load the image, wait for package management to respond, then run a smoke assertion before the main suite. Test a saved snapshot in a disposable AVD before trusting it in CI. If the smoke check fails, rebuild the baseline rather than layering repairs onto corrupted state.
Fit snapshots into automated pipelines
A typical pipeline order is restore, verify, install, test and report. Keep these operations in one wrapper so a failed readiness check stops before the test runner:
adb emu avd snapshot load ui-clean
adb shell 'until [ -n "$(pm path android)" ]; do sleep 1; done'
./gradlew connectedDebugAndroidTest
Treat restored boot completion as a signal, not proof that every system service is ready.
On ephemeral CI workers, saving a snapshot for every job erases its value. Provision a golden runner image or cache the AVD directory, including its snapshot, across runs. Keep the cache keyed to emulator and system-image versions so old state is never paired with a new runtime. Parallel shards need separate AVDs and snapshots; a shared writable device creates races.
This resembles an automated release workflow, where a known artefact is prepared once and a narrow operation repeats reliably. The value comes from reusing verified work rather than skipping validation. Applying the same idea to virtual devices turns snapshot maintenance into an explicit engineering concern instead of hidden test setup.
Australian teams often need banking, retail and small-business variants. The local app market expects Australian English, A$ formatting and GST-inclusive totals. Keep currency and locale fixtures separate from reusable device state rather than saving one image for every product combination.
Keep restored state predictable
Restoration reuses data as well as boot state. Clear or uninstall the target application between tests whenever a test mutates its database, preferences or accounts. An Espresso rule that reinstalls the APK can still leave shared system state, so document every assumption baked into the image.
Handle permissions and network conditions as deliberate fixtures. Pre-grant only permissions that the test is not meant to exercise, and keep the permission-dialog flow in a dedicated test. Run deterministic UI suites against a local stub or controlled test server; use Australian mobile network conditions separately for exploratory checks.
A cached emulator image is still a data artefact. If test records contain identifiable personal information, the Privacy Act 1988 and Australian Privacy Principles can govern their handling, so use synthetic fixtures rather than real customer records. Reset locale, time zone and clock too: Australian base offsets range from UTC+8 in Perth to UTC+10 in Brisbane, with daylight-saving changes in between.
Keep diagnostics with the snapshot workflow. Capture logcat, emulator console output and a screenshot when a restored run diverges from a cold run. Compare process and package state before deciding whether to reload. If a baseline has become unpredictable, discard it and regenerate the known-good image.
Compare the available startup strategies
Snapshots sit between cold boots and fully isolated devices. They are excellent for repeated scenarios that share a defined starting state, but they are poor substitutes for isolation when each test must begin from a pristine filesystem.
For parallel shards, fresh AVDs provide cleaner boundaries even when setup is slower. Gradle Managed Devices can coordinate device pools and cached test images, but its abstraction may hide snapshot controls. Physical device farms remain valuable for hardware fidelity, not for the cheapest rapid feedback loop.
The practical options differ along startup cost, state control and operational overhead.
| Strategy | Startup | State control | Good fit | Main trade-off |
|---|---|---|---|---|
| Cold boot | Slow | Strongest clean-state assurance | Reference validation | Repeated setup time |
| Named snapshot | Fast | Known, reusable state | Repetitive UI scenarios | Requires stale-state discipline |
| Fresh AVD | Medium to slow | Isolated per run | Parallel shards | Image creation and storage |
| Gradle managed devices | Cache-dependent | Scoped Gradle lifecycle | Gradle-integrated suites | Less direct snapshot control |
| Physical device farm | Variable | Real hardware behaviour | Final compatibility checks | Cost, latency and variability |
For a suite dominated by repeated launches, named snapshots usually provide the strongest balance. Keep one cold boot and one clean AVD as references so a fast restored run can always be checked against an uncontaminated environment.
Run the first snapshot pilot
Treat rollout as a controlled pilot rather than a repository-wide convention. Use these checks before the first run:
- Pin the emulator package, system image, API level and AVD profile.
- Record a clean baseline with system services healthy and animations disabled.
- Save the baseline from an idle emulator and verify it in another AVD.
- Add cold and restored startup timings to the test report.
Keep these controls active throughout CI:
- Wait for package-manager readiness before starting the test runner.
- Clear persistent application data whenever a test mutates it.
- Keep permissions, network stubs, locale and clock resets in shared setup code.
- Capture diagnostics on failure, then rebuild the baseline if it no longer matches.
Add one named baseline snapshot to the next Android UI test job, capture cold and restored startup timings, and keep the workflow only when the speed-up is reproducible and the restored state passes the same health checks.
cat ~/interests.json
| Key | Value |
|---|---|
| editor | Terminal-first workflow |
| os | Mac OS X / Unix |
| vcs | Git, distributed version control |
| deploy | Capistrano, cron automation |
| graphics | SVG, Adobe Illustrator troubleshooting |
| networking | IP validation, SSH, VPN |
git log --oneline --reverse
Solving SVG import issues in Adobe Illustrator CS6 and CC
When importing an SVG into Illustrator, the operation fails with an unknown error [CANT]. A workaround for this Adobe-side bug.
Solving NDK build issues on OS X
Troubleshooting native development kit compilation problems on Mac OS X.
Programmatically adding PHP generated TypoScript to the backend configuration
Integrating dynamically generated TypoScript into Typo3 backend setups using PHP.
ArgumentError: Could not parse PKey: no start line
Debugging an SSH key parsing error encountered during deployment.
Validating IP-Addresses in PHP
Using PHP filter functions with flags like FILTER_FLAG_IPV4 and FILTER_FLAG_IPV6, and understanding how filter_var handles reserved IP addresses.
Cocoa: Using NSTrackingArea
A short tutorial on using Cocoa's NSTrackingArea to capture mouseEntered and mouseExited events.
cat ~/contact.txt