apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

Create unit tests for darkness-checking logic

Open domdomegg opened this issue 5 years ago • 18 comments

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

domdomegg avatar Mar 18 '19 07:03 domdomegg

For someone picking this up: it might be useful to reuse the generate image methods from #2626

domdomegg avatar Mar 18 '19 23:03 domdomegg

Added beginner-friendly label, this would be great for a GSoC/Outreachy student.

misaochan avatar Mar 19 '19 11:03 misaochan

Hello @domdomegg @misaochan can i work on this issue ?

silkypriya avatar Mar 20 '19 05:03 silkypriya

Sure take this up @silkypriya

maskaravivek avatar Mar 20 '19 06:03 maskaravivek

Go for it! :)

misaochan avatar Mar 20 '19 09:03 misaochan

Created PR #2727 for this. Kindly review. Thank you!

silkypriya avatar Mar 23 '19 16:03 silkypriya

@misaochan @maskaravivek @nicolas-raoul Can I work on closing this issue?

ciphereck avatar Feb 05 '20 02:02 ciphereck

Yes, sure. It is yours.

maskaravivek avatar Feb 05 '20 02:02 maskaravivek

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 avatar Feb 05 '20 08:02 ciphereck

@ciphereck Please attach a screenshot

ashishkumar468 avatar Feb 05 '20 13:02 ashishkumar468

Screenshot from 2020-02-05 18-49-36

Here it is @ashishkumar468

ciphereck avatar Feb 05 '20 13:02 ciphereck

Such things happen due to invalid-test configurations. To Validate, try this open any Test class and right-click and Run.

ashishkumar468 avatar Feb 05 '20 13:02 ashishkumar468

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 Screenshot from 2020-02-06 13-59-20

ciphereck avatar Feb 06 '20 08:02 ciphereck

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 Screenshot from 2020-02-06 13-59-20

ciphereck avatar Feb 15 '20 13:02 ciphereck

@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.

maskaravivek avatar Feb 15 '20 19:02 maskaravivek

@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?

ciphereck avatar Feb 27 '20 09:02 ciphereck

Hi @misaochan @maskaravivek @nicolas-raoul Can I work on this issue?

gengarrrr avatar Oct 17 '22 02:10 gengarrrr

@gengarrrr Yes thanks! :-)

nicolas-raoul avatar Oct 17 '22 02:10 nicolas-raoul

@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 avatar Oct 25 '22 02:10 gengarrrr

@gengarrrr Good find, please add your oyn test fuctions within that file 🙂

nicolas-raoul avatar Oct 25 '22 09:10 nicolas-raoul