Skip to content

Create unit tests for darkness-checking logic #2649

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

Closed
domdomegg opened this issue Mar 18, 2019 · 20 comments · Fixed by #5096
Closed

Create unit tests for darkness-checking logic #2649

domdomegg opened this issue Mar 18, 2019 · 20 comments · Fixed by #5096

Comments

@domdomegg
Copy link
Member

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 #2639 (comment)

@domdomegg domdomegg changed the title Create tests for darkness-checking logic Create unit tests for darkness-checking logic Mar 18, 2019
@domdomegg
Copy link
Member Author

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

@misaochan
Copy link
Member

misaochan commented Mar 19, 2019

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

@silkypriya
Copy link
Contributor

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

@maskaravivek
Copy link
Member

Sure take this up @silkypriya

@misaochan
Copy link
Member

Go for it! :)

@silkypriya
Copy link
Contributor

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

@ciphereck
Copy link
Contributor

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

@maskaravivek
Copy link
Member

Yes, sure. It is yours.

@ciphereck
Copy link
Contributor

ciphereck commented Feb 5, 2020

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

@ashishkumar468
Copy link
Collaborator

@ciphereck Please attach a screenshot

@ciphereck
Copy link
Contributor

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

Here it is @ashishkumar468

@ashishkumar468
Copy link
Collaborator

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

@ciphereck
Copy link
Contributor

ciphereck commented Feb 6, 2020

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
Copy link
Contributor

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

@maskaravivek
Copy link
Member

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

@ciphereck
Copy link
Contributor

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

@gengarrrr
Copy link
Contributor

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

@nicolas-raoul
Copy link
Member

@gengarrrr Yes thanks! :-)

@gengarrrr
Copy link
Contributor

@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

@nicolas-raoul
Copy link
Member

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

nicolas-raoul pushed a commit that referenced this issue Oct 29, 2022
…six images (#5096)

* add images and test too dark

* add dark and proper images and check if too dar

* test: add refer

Co-authored-by: Ruofan <u7307578@anu.edu.au>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants