Skip to content
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

increase code coverage, especially unit tests #57

Open
anilbey opened this issue Jun 9, 2022 · 9 comments
Open

increase code coverage, especially unit tests #57

anilbey opened this issue Jun 9, 2022 · 9 comments

Comments

@anilbey
Copy link
Contributor

anilbey commented Jun 9, 2022

The coverage is currently (%69) not so high.

More users will try EModelRunner now since the Synplas paper is released.
Increasing the coverage will allow us detect issues before them.

Most tests are functional, we need more unit tests.

@anilbey
Copy link
Contributor Author

anilbey commented Jun 9, 2022

#56 references this issue.

@AurelienJaquier
Copy link
Collaborator

One quick way to increase coverage would be to omit from coverage report the stuff we don't plan on covering anyway. I am thinking of the GUI, or synapses/minis.py.
Aside from that, I agree that we need more unit tests.

@anilbey
Copy link
Contributor Author

anilbey commented Jun 9, 2022

@AurelienJaquier, can we instead add unit tests for the Tkinter GUI at least for its main functions like clicking the start button to run the simulation? GUI module depends on many modules like morphologies, recordings, synapses but the changes made in those modules are not testing if the GUI functions are still compatible.

It seems there are event methods to interact with UI elements, e.g. do a click, enter some value
self.button.event_generate('<Enter>', x=0, y=0)

This is a test file for Tkinter:
https://github.com/python/cpython/blob/main/Lib/idlelib/idle_test/test_tooltip.py#L106
And this is the source code that is tested in the test above:
https://github.com/python/cpython/blob/main/Lib/idlelib/tooltip.py

source: https://www.reddit.com/r/learnpython/comments/hf5uwu/comment/fvvmhsh/?utm_source=share&utm_medium=web2x&context=3

@anilbey
Copy link
Contributor Author

anilbey commented Jun 9, 2022

The GUI module also has simulation functions that need to stay compatible with the rest of the modules. I think it would be good to keep them updated with the future changes.

https://github.com/BlueBrain/EModelRunner/blob/main/emodelrunner/GUI_utils/simulator.py#L177

@AurelienJaquier
Copy link
Collaborator

Thank you for the links, this will help. I'll add some tests for the GUI module then.

anilbey added a commit that referenced this issue Jun 9, 2022
* add unit tests for json utilities

* replace try-except-pass with contextlib.suppress

* add unit test to cover runtimerror raised in creating protocols

* add test_np_encoder_float for NpEncoder

* separate create_protocol and reader unit tests
@anilbey
Copy link
Contributor Author

anilbey commented Jul 1, 2022

#59 adds unit tests for GUI/simulator

@AurelienJaquier
Copy link
Collaborator

I am afraid we won't be able to test the frames, buttons, and other tkinter stuff. For that, we need a graphical environment, and it looks like we don't have one in github actions (source: https://github.com/python/cpython/blob/main/Lib/idlelib/idle_test/README.txt#L47).

@wvangeit
Copy link
Contributor

wvangeit commented Jul 4, 2022

Yeah, not sure if we need to test that. If you really want to, I think @alex4200 has something running on our systems to test GUIs?

@anilbey
Copy link
Contributor Author

anilbey commented Jul 4, 2022

Ok, covering GUI module's simulation related code was the critical part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants