Skip to content

Conversation

@cortinico
Copy link
Contributor

Summary:
This is a reference PR on how to convert a JVM Unit test from Java to Kotlin. A couple of things to keep in mind when converting:

  1. Do not use hungarian notation (mActivity -> activity)
  2. JUnit rules need to be annotated with get:Rule rather than just Rule.
  3. Use import org.powermock.api.mockito.PowerMockito.when as wheneverto avoid having to escape all the when function invocation in the code as it's a keyword.
  4. Do static imports of all the Mockito/PowerMock functions.

Getting rid of PowerMock and using Fakes is a plus, but that's not always possible. Having the test running and be green is already a good result.

Changelog:
[Internal] [Changed] - Convert RootViewTest to Kotlin

Differential Revision: D45526517

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels May 3, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45526517

cortinico added a commit to cortinico/react-native that referenced this pull request May 3, 2023
Summary:
Pull Request resolved: facebook#37227

This is a reference PR on how to convert a JVM Unit test from Java to Kotlin. A couple of things to keep in mind when converting:

1. Do not use hungarian notation (`mActivity` -> `activity`)
2. JUnit rules need to be annotated with `get:Rule` rather than just `Rule`.
3. Use `import org.powermock.api.mockito.PowerMockito.`when` as whenever`to avoid having to escape all the `when` function invocation in the code as it's a keyword.
4. Do static imports of all the Mockito/PowerMock functions.

Getting rid of PowerMock and using Fakes is a plus, but that's not always possible. Having the test running and be green is already a good result.

Changelog:
[Internal] [Changed] - Convert RootViewTest to Kotlin

Reviewed By: cipolleschi

Differential Revision: D45526517

fbshipit-source-id: 681482f3445fa4f0153a40ddbdf50a13cb5d35f2
@cortinico cortinico force-pushed the export-D45526517 branch from c4f8235 to 58bb00d Compare May 3, 2023 14:18
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45526517

@analysis-bot
Copy link

analysis-bot commented May 3, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,628,586 +1
android hermes armeabi-v7a 7,940,682 +2
android hermes x86 9,115,572 +2
android hermes x86_64 8,970,184 +3
android jsc arm64-v8a 9,192,771 +5
android jsc armeabi-v7a 8,382,322 +3
android jsc x86 9,251,104 +2
android jsc x86_64 9,509,353 +3

Base commit: ab3a2f4
Branch: main

Summary:
Pull Request resolved: facebook#37227

This is a reference PR on how to convert a JVM Unit test from Java to Kotlin. A couple of things to keep in mind when converting:

1. Do not use hungarian notation (`mActivity` -> `activity`)
2. JUnit rules need to be annotated with `get:Rule` rather than just `Rule`.
3. Use `import org.powermock.api.mockito.PowerMockito.`when` as whenever`to avoid having to escape all the `when` function invocation in the code as it's a keyword.
4. Do static imports of all the Mockito/PowerMock functions.

Getting rid of PowerMock and using Fakes is a plus, but that's not always possible. Having the test running and be green is already a good result.

Changelog:
[Internal] [Changed] - Convert RootViewTest to Kotlin

Reviewed By: cipolleschi

Differential Revision: D45526517

fbshipit-source-id: 25545883eaa88cae5f6603670767fcca059a82a4
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45526517

@cortinico cortinico force-pushed the export-D45526517 branch from 58bb00d to 3c70ef9 Compare May 3, 2023 16:03
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 3, 2023
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 71fbb0c.

@facebook-github-bot
Copy link
Contributor

This pull request has been reverted by fe5455b.

jeongshin pushed a commit to jeongshin/react-native that referenced this pull request May 7, 2023
Summary:
Pull Request resolved: facebook#37227

This is a reference PR on how to convert a JVM Unit test from Java to Kotlin. A couple of things to keep in mind when converting:

1. Do not use hungarian notation (`mActivity` -> `activity`)
2. JUnit rules need to be annotated with `get:Rule` rather than just `Rule`.
3. Use `import org.powermock.api.mockito.PowerMockito.`when` as whenever`to avoid having to escape all the `when` function invocation in the code as it's a keyword.
4. Do static imports of all the Mockito/PowerMock functions.

Getting rid of PowerMock and using Fakes is a plus, but that's not always possible. Having the test running and be green is already a good result.

Changelog:
[Internal] [Changed] - Convert RootViewTest to Kotlin

Reviewed By: cipolleschi

Differential Revision: D45526517

fbshipit-source-id: e0cf650126659fdc8676fb32e1617ad51ca14e11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner Reverted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants