Сохранять фиктивные данные доступными только для тестирования и androidTestAndroid

Форум для тех, кто программирует под Android
Anonymous
Сохранять фиктивные данные доступными только для тестирования и androidTest

Сообщение Anonymous »


I have mock data that I want to use for both unit and instrumented test. To avoid repetition, I created a common directory testHelper and placed my mock data there. In app/build.gradle I did:

Код: Выделить всё

sourceSets {
androidTest {
java.srcDirs += 'testHelper'
}

test {
java.srcDirs += 'testHelper'
}
}
Now i can import my mock data from unit and UI tests but I can also access them from the main app. I want to avoid doing that. I tried a few tips such as adding src/ to the above but it made no difference.
basically, I don't want my main code to access the mock data

Код: Выделить всё

import AppMockData // ==> this shouldn't work. currently it does.

@Composable
fun HelloWorld(){}


Источник: https://stackoverflow.com/questions/781 ... ndroidtest

Вернуться в «Android»