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
Fix an issue that Android Instrumentation Test fails #895
Fix an issue that Android Instrumentation Test fails #895
Conversation
After checking at hand, another problem arises.
|
…aining unnecessary classes
It is fixed at f770509. |
@@ -3,15 +3,24 @@ import buildsrc.config.asProvider | |||
import com.android.build.gradle.internal.tasks.DexMergingTask | |||
|
|||
plugins { | |||
buildsrc.convention.`android-application` | |||
id("com.android.application") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed android-application.gradle.kts
since it is not used except for android-dispatcher
module.
Instead, I moved the contents of android-application.gradle.kts
to this build.gradle.kts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's intentional that build config that is shareable is defined in buildSrc, even if it's only used in one place. It helps keep the build logic organised and consistent. It makes it easier to compare and contrast the Android Library config to the Android Application config, and easier to see if there's any special treatment that's needed in the subprojects. So I think this should be reverted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, I think it is better to remove android-application.gradle.kts
.
:mockk-agent-android-dispatcher
module is a very specific Android Application module that only extracts the final DEX file, and the build configuration is completely independent and non-reusable.
If we were to add an Android sample application module in the future and try to reuse the configuration with :mockk-agent-android-dispatcher
module, it would add an unnecessary dependency to :mockk-agent-android-dispatcher
module and cause the same problems that encountered in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think the dependency on :mockk-agent-android-dispatcher
should be removed from the buildSrc script
edit: I read your comment too quickly and my response doesn't make sense! I'll have another look
Do you know if there's a good way to write an automated test for this? |
How about adding a verification task to make sure that the By the way, it seems that there is already an Android Instrumentation Test for https://github.com/mockk/mockk/runs/7992536177?check_suite_focus=true
I was getting the following error on my local.
|
androidTestImplementation(kotlin("test")) | ||
androidTestImplementation(kotlin("test-junit")) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝I thought it would be better to make the test configs common, so I moved them here.
} | ||
|
||
testOptions { | ||
execution = "ANDROIDX_TEST_ORCHESTRATOR" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Using Test Orchestrator makes Instrumentation Test stable. Documentation
|
||
defaultConfig { | ||
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" | ||
testInstrumentationRunnerArguments["notAnnotation"] = "io.mockk.test.SkipInstrumentedAndroidTest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝This class was not included in the test APK and an error log was displayed, so I remove this notAnnotation
config.
@Rule | ||
@JvmField | ||
val rule = ActivityTestRule(TestActivity::class.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Removed because it's unnecessary.
@kubode thanks a lot for putting this together. Is this complete? Can we merge it? |
#899 does not resolve all issues. Or should I revert the convention plugin and fix the convention plugin so that the |
good point! Can you revert the convention plugin changes, then apply the specific fixes to the subproject's |
It is possible, however in that case we need to remove Kotlin plugins from the |
Remove mockk/buildSrc/src/main/kotlin/buildsrc/convention/android-library.gradle.kts Lines 9 to 10 in b72cf14
|
Fixed! |
Ah okay, I thought that mockk/plugins/configuration/src/main/kotlin/io/mockk/configuration/AndroidConfigurationPlugin.kt Lines 32 to 37 in 1d1e6a8
But if it's not necessary, then it can be removed. |
In |
Ah good point, I got confused between |
# Conflicts: # modules/mockk-android/build.gradle.kts
To fix #894.