Skip to content

The option wiring has no test seam #81

Description

@xroche

OptionsEmissionTest can only reach the mapper classes in isolation. The tables that wire a checkbox to an engine flag (fieldsSerializer id to name, fieldsDefaults, fieldsMapper) are unreachable from a plain JUnit test: they are built in OptionsMapper's static initialiser out of android.util.Pair and R.id, and the stub android.jar throws RuntimeException("Stub!") from the Pair constructor. The nested mapper classes only work because a static nested class does not trigger the outer initialiser. returnDefaultValues does not help, since the stub nulls both fields before it throws.

So a row pointing at the wrong option name, a checkbox left out of a tab's @Fields (saved but never reloaded), or a missing defaults entry all ship green. That is how the three new options landed in #77: the emitter is covered, the wiring behind it is not.

Two ways out. Add Robolectric, which gives real Pair, SparseArray and R.id without a device. Or drop android.util.Pair from the static tables for a local immutable pair, and lift the mapping loop out of buildCommandline() into a static that takes a name-to-value lookup and returns the argv. The second keeps the test dependency-free; SparseArraySerializable and the Context work stay untestable either way, which is fine because they are not where the bugs are.

Either one unlocks the assertion that matters: tick checkSitemap, get --sitemap in the argv and nothing added to the packed flag string, plus a table-consistency check that every serializer name has both a default and a mapper.

Worth noting for whoever picks this up: the engine's own self-tests (-#test=singlefile, -#test=changes) should be reachable through HTTrackLib.main, so an instrumentation test could exercise the real engine paths on a device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions