BeksOmega / looping-layout

A looping LayoutManager for the Android RecyclerView.
Apache License 2.0
271 stars 16 forks source link

Improve Test Readability #49

Closed BeksOmega closed 3 years ago

BeksOmega commented 3 years ago

:key: Use case

The current unit tests are hard to read and understand. This makes it hard to fix things if the tests ever break.

:hammer: Proposal

Test names

Currently there are tests for all different combinations of orientations, scrolls, settings, etc, which is great! But the test names don't reflect this very well.

Ideally I would create nested suites, eg Horizontal > LTR > Not Reversed > etc, but that doesn't seem easy to do in Android.

Instead I propose moving to a naming convension like horiz_ltr_notRev to try to simulate suites, and make the tests a bit more clear.

Test comments

For many of the tests (especially the ScrollTo ones) it is hard to visualize what the different scrolls are actually doing, and how that affects the test.

I propose adding simple ascii-art diagrams above the relevant calls to try to make the tests clearer. For example, showing the position of the filler views vs the target view, relative to the screen, after each call.

For example:

// This shows that the target view (T) is aligned with the left edge of the screen,
// and the filler view (F) is partially off screen to the right.
// |(-T-)(----F-|--)

General

There are also some general test-health things that need to be taken care of. For example, some tests aren't properly setting up the adapter before runing, and others have incorrect assertions. But these things need to be handled on a case-by-case basis.

:wrench: Alternative

N/A

:memo: Other info

N/A

:bee: Request for assignment

I'll take this until I get one set of tests refactored (so it can be used as an example). Then I'll post more info so other people can take a crack at it :D

BeksOmega commented 3 years ago

Closed via #55