Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Code health] Packing Structure of Unit Test #2504

Open
anandwana001 opened this issue Jun 20, 2024 · 3 comments
Open

[Code health] Packing Structure of Unit Test #2504

anandwana001 opened this issue Jun 20, 2024 · 3 comments
Labels
type: code health Improvements to readability or robustness of codebase

Comments

@anandwana001
Copy link
Contributor

Currently, some of the files are there at the parent level of the unit test module, which can be cluttered if increases in the future (As the code grows, the files definitely increase in this area)

This can be fixed by putting each file in their respective packages. This re-structuring will not affect what packaging structure we are following in the main module, as all these are helper classes for testing purpose only.

Suggestion

unitTest/java/com/google/android/ground
├── domain
├── hilt
│   ├── BaseHiltTest
│   └── HiltExt.kt
├── mockito
│   └── MockitoKotlinHelpers.kt
├── model
├── module
│   ├── TestAuthenticationModule
│   ├── TestCoroutineDispatchersModule
│   ├── TestCoroutineScopesModule
│   ├── TestRemoteStorageModule
│   ├── TestWorkManagerModule
│   └── TestLocalDatabaseModule
├── navigation
│   └── NavigationTestHelper.kt
├── persistence
├── repository
├── system
├── ui
├── util
│   └── ResultAssertions.kt
├── view
│   ├── RecyclerViewHelper.kt
│   ├── CustomViewActions
│   └── UiTestHelper.kt
├── MainActivityTest
└── MainViewModelTest
@anandwana001 anandwana001 added the type: code health Improvements to readability or robustness of codebase label Jun 20, 2024
@shobhitagarwal1612
Copy link
Member

shobhitagarwal1612 commented Jun 20, 2024

Can we keep all of the helpers and utils under a same directory?

It would also be nice to rename some of the helper classes to *Ext if it only contains extension functions for consistency

@anandwana001
Copy link
Contributor Author

Can we keep all of the helpers and utils under a same directory?

So, as the helpers are moe categorised, like mockito helpers, di helpers, view helpers, so if we put all them in one, it would be hard to understand what helpers it consist of.

It would also be nice to rename some of the helper classes to *Ext if it only contains extension functions for consistency

Correct, extensions should be named with suffix Ext, nice idea.

@gino-m
Copy link
Collaborator

gino-m commented Jun 27, 2024

Can we keep all of the helpers and utils under a same directory?

It would also be nice to rename some of the helper classes to *Ext if it only contains extension functions for consistency

+1 to @anandwana001's comment. There are different types of ext functions / helpers in the codebase; keeping them close to where they're used helps make their scope clear. Top-level language helpers (e.g. for converting between basic types) can go somewhere under the top level, but I wouldn't imagine domain or architecture specific like HiltExt.kt also living under that directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: code health Improvements to readability or robustness of codebase
Projects
Status: No status
Development

No branches or pull requests

3 participants