Edit: Found out that MockK is causing this issue. I guess it is duplicating these files when I'm mocking my API request. When I remove MockK and/or Mockito. I do not get these errors. Any ideas?
Getting this error stating that there are these duplicate meta data files. I tried adding the packagingOptions block in my build.gradle file to exclude these files, but then my tests won't run at all. Is there a way to manually remove the duplicates? Where would these files be located? Any help is greatly appreciated. I am lost lol.
Tests:
@RunWith(AndroidJUnit4::class)
class ViewModelTests {
@get:Rule(order = 1)
val testRule = ActivityScenarioRule(MainActivity::class.java)
private lateinit var viewModel: NewsViewModel
private lateinit var repositoryImpl: RepositoryImpl
private val context = InstrumentationRegistry.getInstrumentation().targetContext
@Before
fun setUp() {
val newsDao = NewsDatabase.getDatabase(context).myDao()
val newsApi = mockk<NewsApi>()
viewModel = mockk()
repositoryImpl = RepositoryImpl(newsApi, newsDao)
}
@Test
fun test_empty_database() = runBlocking {
assertEquals(0, repositoryImpl.getNewsFromDatabase.value?.size)
}
}
Error: Execution failed for task ':app:mergeDebugAndroidTestJavaResource'.
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction 6 files found with path 'META-INF/LICENSE.md' from inputs: - /Users/sammorton/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-params/5.8.2/ddeafe92fc263f895bfb73ffeca7fd56e23c2cce/junit-jupiter-params-5.8.2.jar - /Users/sammorton/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-engine/5.8.2/c598b4328d2f397194d11df3b1648d68d7d990e3/junit-jupiter-engine-5.8.2.jar - /Users/sammorton/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-api/5.8.2/4c21029217adf07e4c0d0c5e192b6bf610c94bdc/junit-jupiter-api-5.8.2.jar - /Users/sammorton/.gradle/caches/modules-2/files-2.1/org.junit.platform/junit-platform-engine/1.8.2/b737de09f19864bd136805c84df7999a142fec29/junit-platform-engine-1.8.2.jar - /Users/sammorton/.gradle/caches/modules-2/files-2.1/org.junit.platform/junit-platform-commons/1.8.2/32c8b8617c1342376fd5af2053da6410d8866861/junit-platform-commons-1.8.2.jar - /Users/sammorton/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter/5.8.2/5a817b1e63f1217e5c586090c45e681281f097ad/junit-jupiter-5.8.2.jar Adding a packagingOptions block may help, please refer to https://developer.android.com/reference/tools/gradle-api/7.3/com/android/build/api/dsl/ResourcesPackagingOptions for more information
mockk
1.12.7 is the first version that causes it for me. Lower versions work OK. Is that the same for you too? – Cultivar