Closed JHartzer closed 1 year ago
@JHartzer, thank you for the recommendation! I did not know pytest-cov. I have worked on increasing the code coverage of the behaviors
class and I was able to increase it from 88% to 98%. However, I could not handle that much the swarm
class due to the plt.show()
inside simulate()
. So, it increased from 14% to 39% only. I would appreciate it if you have any suggestions on how to overcome that.
Excellent! Typically you can get around the plotting test coverage limitation by separating the simulation from the plotting routines. For example, if simulate()
produced an array of state data, and a separate animate()
function ingested those states and produced the animation. That way, you could test the simulation portion of the code and ignore the plotting.
Great! Thanks for the suggestion! Instead of separating and adding one more step to the new users, I have created a mode
argument for simulate()
, so, it is possible to just get the states, get the animation object, or produce the animation. Now the code coverage increased from 39% to 82% 😃
I recommend making use of pytest-cov or any other coverage tool to calculate and track overall code coverage. I've included an initial high-level pass at the current state of testing below:
It is apparent that most of the main behavior functions are being tested, but the main
swarm
class is not. I believe adding tests for the swarm class initialization and simulation would improve this work. Simply adding the two examples in a test function would likely be sufficient.