单元测试和joda-time-android

Ale*_*ndr 5 android jodatime mosby

joda-time-androidPresenter课堂上使用了库的类,它不能有任何Android依赖项.所以我无法正确测试它.我知道我可以使用Robolectric这个,但我想要避开这个工具和我的Presenter干净.我应该放弃JodaTime吗?还有其他方法吗?

Ale*_*ndr 11

因为Unit-tests我们可以使用JodaTime库的默认java实现,因为它具有相同的包和类joda-time-android.

// for android
compile 'net.danlew:android.joda:2.9.3'

// joda-time for tests
testCompile 'joda-time:joda-time:2.9.3'
Run Code Online (Sandbox Code Playgroud)

奇迹般有效.

对于其他图书馆的其他案例,请参阅@npace的回答.