apps-android-commons
apps-android-commons copied to clipboard
Create unit tests for darkness-checking logic
Summary:
Would be good to have a unit test for the darkness checking algorithm. It could use the 4 images in #1767 as samples.
See https://github.com/commons-app/apps-android-commons/pull/2639#issuecomment-473773865
For someone picking this up: it might be useful to reuse the generate image methods from #2626
Added beginner-friendly label, this would be great for a GSoC/Outreachy student.
Hello @domdomegg @misaochan can i work on this issue ?
Sure take this up @silkypriya
Go for it! :)
Created PR #2727 for this. Kindly review. Thank you!
@misaochan @maskaravivek @nicolas-raoul Can I work on closing this issue?
Yes, sure. It is yours.
I wrote some tests of ImageUtils class. But I'm not able to run it. It shows error "No tests were found". I try to run tests using both ImageUtilsTest Class and the test function I created. But it's showing the same error. It's showing the same error, for tests written in the past as well by someone else. Also, some test classes are giving NoClassDefFoundError while testing. Can anyone help? @maskaravivek @nicolas-raoul
@ciphereck Please attach a screenshot
Here it is @ashishkumar468
Such things happen due to invalid-test configurations. To Validate, try this open any Test class and right-click and Run.
Hi,
I'm getting a problem. When I'm writing tests for ImageUtils class.
The line number 99 ( bmp = BitmapFactory.decodeFile(imagePath); ) which is supposed to convert an image into bitmap is always returning null when I'm calling it from the text file.
I tried whether it is the same case when running on mobile with debugging, but on mobile while debugging it's working just fine and returning bitmap as required.
While testing it returns null always.
Can anyone help? @ashishkumar468 @maskaravivek @nicolas-raoul @misaochan @neslihanturan
Hi,
I'm getting a problem. When I'm writing tests for ImageUtils class.
The line number 99 ( bmp = BitmapFactory.decodeFile(imagePath); ) which is supposed to convert an image into bitmap is always returning null when I'm calling it from the text file.
I tried whether it is the same case when running on mobile with debugging, but on mobile while debugging it's working just fine and returning bitmap as required.
While testing it returns null always.
Can anyone help? @ashishkumar468 @maskaravivek @nicolas-raoul @misaochan @neslihanturan
@ciphereck While running a unit test BitmapFactory.decodeFile
won't be available and you might need to mock it as its a static class. See FileUtilsWrapper
and FileUtils
to see how it can be done.
@misaochan @maskaravivek I tried mocking ImageUtils as static class using wrapper as was in FileUtilsWrapper. There's already a wrapper for ImageUtils i.e. ImageUtilsWrapper, but it's still returning null to me.
I also tried @RunWith as mentioned in StackOverflow somewhere, but it's still of no help :( Can you please help me on this?
Hi @misaochan @maskaravivek @nicolas-raoul Can I work on this issue?
@gengarrrr Yes thanks! :-)
@nicolas-raoul. Hello, I found that there already exists an ImageUtilsTest file, and I think it contains the check for dark with no image example through the merged pull request of Add ImageUtils Tests #4542. Should I just work on adding some images? or Can I write my own test functions within the file. Thank you
@gengarrrr Good find, please add your oyn test fuctions within that file 🙂