question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is Robolectric a requirement for loading a ZoneInfoProvider? Could there be a mechanism for loading such that doesn’t depend on Android APIs?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

62reactions
anothemcommented, Sep 21, 2015

I’ve done this by using the standard JVM backport package for unit testing. testCompile 'org.threeten:threetenbp:1.3.1'

Still experimenting, but haven’t run into any issues so far.

47reactions
vdubedoutcommented, Oct 21, 2016

To resume for people passing around.

app/build.graddle

dependencies {
    [...]
    compile 'com.jakewharton.threetenabp:threetenabp:1.0.4'
    testCompile ('org.threeten:threetenbp:1.3.2'){
        exclude group:'com.jakewharton.threetenabp', module:'threetenabp'
    }
    testCompile('org.robolectric:robolectric:3.1.2') {
        exclude group: 'commons-logging', module: 'commons-logging'
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    [...]
}

Test class

@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, application = TestApp.class)
public class MessagingTimeFormatterTest {
    [...]
}

TestApp without AndroidThreeTen.init(this)

public class TestApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
    }
}

-> clean & build

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit testing - Wikipedia
In computer programming, unit testing is a software testing method by which individual units of source code—sets of one or more computer program...
Read more >
Unit Testing Tutorial – What is, Types & Test Example - Guru99
Unit Testing is a type of software testing where individual units or components of a software are tested. The purpose is to validate...
Read more >
What Is Unit Testing? - SmartBear
Unit Testing is the process of checking small pieces of code to deliver information early and often, speeding your testing strategies, and reducing...
Read more >
Unit Testing | Software Testing - GeeksforGeeks
Unit Testing is defined as a type of software testing where individual components of a software are tested. Unit Testing of the software...
Read more >
Unit testing fundamentals - Visual Studio (Windows)
Check that your code is working as expected by creating and running unit tests. It's called unit testing because you break down the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found