I am developing an android library.
The library takes in some parameters. For instance, it has a setStyle method which takes in a reference to a style resource:
fun setStyle(@StyleRes style: Int) ...
I want to test this method. To do this, I want to pass a resource TestStyle to the library in a unit test. Something like this:
myLibrary.setStyle(R.style.TestStyle)
However, I don't want to create the TestStyle resource in the main src/main/res/values/styles.xml because this would make the resource available to people using my library. I want it to only be available in tests.
Instead, I tried to place the TestStyle <item /> in a new test-only file at src/test/res/values/styles.xml. However, I can't figure out how to access this in the unit test, as it is not available through R.
How can I create resources that are only accessible in tests and not in other parts of the code?
Aucun commentaire:
Enregistrer un commentaire