Usage in unit testing
See original GitHub issueWhen unit testing the Android app (junit.framework.TestCase or Junit 4 tests from a pure submodule) joda-time-android cannot be used as it requires a context as part of the JodaTimeAndroid.init
ialization.
The alternative is to obviously just use joda-time for submodules and converting TestCase
s to AndroidTestCase
s (in the process getting hold of a context for initialization).
In you experience have you had to deal with a similar case and if so did you choose an alternative nicer approach for unit testing? Conceptually it would be nice to have the exact same JodaTime library used for both testing and production, but is this just a limitation that can’t be overcome?
Cheers
Issue Analytics
- State:
- Created 9 years ago
- Reactions:3
- Comments:10 (4 by maintainers)
Top Results From Across the Web
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? Definition from WhatIs.com - TechTarget
Unit testing is a software development process in which the smallest testable parts of an application, called units, are individually and independently ......
Read more >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 >What is the Use of Unit Testing? - The Official 360logica Blog
Unit testing is a software testing methodology which involves testing of individual units of source code to check whether they are fit to...
Read more >Unit Testing: Definition, Examples, and Critical Best Practices
It is used to determine if code changes can harm or interfere with the way an application behaves or consumes resources. In general,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a bit late but if anyone stumbles here, unfortunately not all of modules were pure java, but thankfully most of the package names and functionality in joda time android is similar to joda time, so for running jvm unit tests you can do something like
testCompile "joda-time:joda-time:${jodaTimeVersion}"
Although this won’t work for classes or modules where you are using jodaTimeAndroid exclusive classes, but in my case i was able to successfully use it in a lot of places
@dlew i am assuming there shouldn’t be any side effects with this approach like possible flaky tests
True, so I guess most people can do jvm tests without any problem for the most part On 20-Dec-2015 1:03 am, “Daniel Lew” notifications@github.com wrote: