New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClassNotFoundException when running in UnitTest #120
Comments
You mean like minidns/minidns-client/src/main/java/org/minidns/dnsserverlookup/AndroidUsingReflection.java Lines 76 to 78 in e0a137f
I am not sure why this doesn't work for you. How do you invoke the unit tests?
Hardcoded DNS servers are a sensitive topic due the privacy implications. I tend to change MiniDNS so that they are not populated by default, and provide convenience methods like |
Thank you for your answer. After reviewing my code I found out that it is not crashing, but it is logging that exception. However since I still get the error logged that To be honest I just executed the test from Android Studio, I would guess that this executes in the background e.g. gradle test task. |
I think what basically happens is that Android Studio executes the unit tests in an Android(-ish) environment, so that PlatformDetection.isAndroid()
How would that fix it? |
That code could detect if junit is present and therefor not on a real device, however your solution is much better. |
I'm evaluating this library for a project and I started using it in a UnitTest, but it crashes:
In my opinion you should check first if you are running on Android before executing Android specific code. I just want to quote the first sentence of the readme: "MiniDNS [...] is a DNS library for Android and Java SE." A unit test falls in my opinion in that case.
I like the idea of fallback to a fixed DNS server, but why just one IPv4 and IPv6? Google has 2 of both and there are also public alternatives like 1.1.1.1 or 9.9.9.9
When I find some free time I will create a PR in order to fix that. If anyone else is quicker then go on, that part is no rocket science.
The text was updated successfully, but these errors were encountered: