简体   繁体   中英

Class Duplication during Test with robolectric and flavors in android

I'm working on a project using Robolectric, gradle flavors and wireMock to mock my webservices with the following folder structure:

app
   main (common classes)
flavor1
   Constant (class with url for this flavor)
flavor2
   Constant (class with url for this flavor)
testDebug
   Constant (class with url pointing to wireMock standalone)
   Common test for flavor1 and flavor2
testFlavor1
   Particular tests for flavor1
testFlavor2
   Particular tests for flavor2

I'm getting a "Duplicate class found" error class on testDebug/Constant class. Even with this error on Android Studio, I'm able to compile and run the test without any problem.

Are there any way to suppress the error from the Android Studio or any other way to implement the same functionality?

Thanks.

Finally I managed to remove the duplicate class error, I removed the class from test folder, I added the test url in the constant file and then I initialized my communication manager to use the url test before start run any tests. Simple and stupid :P!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM