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

NT-1738: Android Segment Refactor: Create TestApplicationModule #1074

Merged
merged 6 commits into from
Jan 25, 2021

Conversation

Arkariang
Copy link
Contributor

📲 What

  • KSRobolectric migrated to kotlin
  • KSRobolectrict using ApplicationProvider instead of deprecated RuntimeEnvironment.application;
  • Avoid any initialization of third party libraries on KSApplication.java when running unit tests.
  • Updated library joda to version 2.9.3 is not the newest one, but the latest one we can use without changing any test.

🤔 Why

The ApplicationModule was used on RobolectricTestCase for populating the environment object, instanciating all the third party libraries, later on that environment object was reloaded with all the mock clients. Avoid that first initialization by using the new TestApplicaionModule

📋 QA

  • This changes only involve test environment

Story 📖

NT-1738: Create TestApplication Module

… one used un production code

- use ApplicationProvider.getApplicationContext() instead of the deprecated  this.application = (TestKSApplication) in test Application
- migrated KSRoboelectricTestCase to kotlin
- Protect the inicialization of multiple libraries/lifecycles for not being triggered on Testing
- add again fix date
@@ -154,6 +156,8 @@ public void testProjectsForBottomSheet_WithManyProjects() {

@Test
public void testProjectSwitcherProjectClickOutput() {
DateTimeUtils.setCurrentMillisFixed(new DateTime().getMillis());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 This is needed for the test to keep working, it was done before on KSRobolectricTestCase.java:51 it has been isolated just for the concrete test.

val lakeTrackingClient = lakeTrackingClient(mockCurrentConfig, experimentsClientType)

val component = DaggerApplicationComponent.builder()
.applicationModule(TestApplicationModule(application()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏 👏

Copy link
Contributor

@leighdouglas leighdouglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! This is awesome 🎉

@Arkariang Arkariang merged commit 6e1f5ab into master Jan 25, 2021
@Arkariang Arkariang deleted the imartin/NT-1738-test-application-module branch January 25, 2021 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants