What I am doing
I am beginning to get an idea of what unittests are. They try to test a particular small portion of your code and ensure that it will behave normally in all test cases.
For example I was writing unittests for a function - set_video_port(video_port) Mithro pointed out that if I give an argument like -1, my code will not work correctly. So this type of error where the port numbers are not in range should induce a ValueError. Similary, putting a string as an argument will should also raise an exception - TypeError.
I am making a class for each function, and the functions in the class are corresponding tests The format is like:
I run these tests by simply issuing a command like
The commits made are
- Added unittest for BaseServer.get_record_file: b5e4a4002c33d9f9a2c97184e6d9eacbeaad06a3
- Added unittest for BaseServer.get_control_port: f4ce165cb8f5d6b54c1ae3836025f1e0600ade6d
- Added unittest for BaseServer.get_audio_port: c8f2ccdf9675dd4ce3b146e35feda6289cce307a
- Added unittest for BaseServer.get_video_port: 933598967c845f394d2744322b1063b583bb53a9
- Added unittest for BaseServer.set_record_file: a403b96a3baaab320578530b2ebfc502cf1973b3
- Added unittest for BaseServer.set_control_port: ab2743e221b45c980a75a9e9464f6ea61f6748a0
- Added unittest for BaseServer.set_control_port: b4584d1c9214a555af052b7542adfa707acc9a1b
- Added unittest for BaseServer.set_audio_port: 761fd99c5519da82c79ee5e31f77cf07769a0b65
- Added unittest for BaseServer.set_video_port: 6963aa5bbbddbe8d25e776ca4727a509132485e5
What I am planning to do
I will be continuing with writing unittests for each function of the code :)
An off-topic thing. Getting all commits I had made in the last days on the blog page was such a headache. I have made this small little script for getting these commits and generating html code out of it https://github.com/hyades/hyades.github.com/blob/master/commits.py
Comments Section
Feel free to comment on the post but keep it clean and on topic.
blog comments powered by Disqus