Discussion:
[gci-discuss] [Unit Testing] Problem with code to be tested
Robin Richtsfeld
2017-12-01 16:25:15 UTC
Permalink
Google Code-In Task: https://codein.withgoogle.com/tasks/5400418718842880/
GitHub
Issue: https://github.com/jboss-outreach/compressor-head-android/issues/16

The objective is to write tests
for https://github.com/jboss-outreach/compressor-head-android/blob/master/app/src/main/java/com/community/jboss/compressorhead/utils/CompressorHead.java
using JUnit.
The problem is that some of the code to be tested is not mocked, which
gives the following error when running the with JUnit:
Method scheme in android.net.Uri$Builder not mocked. See
http://g.co/androidstudio/not-mocked for details.
The android.jar file that is used to run unit tests does not contain any
actual code - that is provided by the Android system image on real devices.
Instead, all methods throw exceptions (by default). This is to make sure
your unit tests only test your code and do not depend on any particular
behaviour of the Android platform (that you have not explicitly mocked e.g.
using Mockito).

Although, everything works when calling the tests from the Activity, I
expect the automated JUnit testing to fail.
--
You received this message because you are subscribed to the Google Groups "Google Code-in Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gci-discuss+***@googlegroups.com.
To post to this group, send email to gci-***@googlegroups.com.
Visit this group at https://groups.google.com/group/gci-discuss.
For more options, visit https://groups.google.com/d/optout.
Ploypiti Piyaprapan
2017-12-02 09:01:53 UTC
Permalink
Hi,
I see that you already reported the issue on the repo, you can also let
your mentor know about this since they are responsible for the task and
they should be able to help you fix the issue. Note that not all GCI
competitor can solve your problem, therefore, posting it here might not
help much, remember that your mentors are happy to help you ;)
-P10YP1T1
Post by Robin Richtsfeld
Google Code-In Task: https://codein.withgoogle.com/tasks/5400418718842880/
https://github.com/jboss-outreach/compressor-head-android/issues/16
The objective is to write tests for
https://github.com/jboss-outreach/compressor-head-android/blob/master/app/src/main/java/com/community/jboss/compressorhead/utils/CompressorHead.java
using JUnit.
The problem is that some of the code to be tested is not mocked, which
Method scheme in android.net.Uri$Builder not mocked. See
http://g.co/androidstudio/not-mocked for details.
The android.jar file that is used to run unit tests does not contain any
actual code - that is provided by the Android system image on real devices.
Instead, all methods throw exceptions (by default). This is to make sure
your unit tests only test your code and do not depend on any particular
behaviour of the Android platform (that you have not explicitly mocked e.g.
using Mockito).
Although, everything works when calling the tests from the Activity, I
expect the automated JUnit testing to fail.
--
You received this message because you are subscribed to the Google Groups "Google Code-in Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gci-discuss+***@googlegroups.com.
To post to this group, send email to gci-***@googlegroups.com.
Visit this group at https://groups.google.com/group/gci-discuss.
For more options, visit https://groups.google.com/d/optout.
Loading...