I usually try to have a positive outlook on my academic life yet it is only the 4th week of the term and everything has already started to pile up and get more complex. However, it does help to remind myself how much I like a good challenge! I look forward to the lab section of this course because my lab partner and I tend to stumble upon little tips and secrets here and there as we figure out the problems given to us. What we discover usually helps me tremendously in comprehending the material during the rest of the week.
This week for example, we were working on classes, subclasses, inheritance and testing of code. As we unravelled bits and pieces of the code, we followed the logic we usually use and then we reached the step where writing a testing method was necessary. Contrary to what we thought was a basic problem, my partner and I faced a dilemma that had us blankly staring at the screen for over 20 minutes. As instructed, we had created a subclass in unittest.TestCase then we wrote the test methods and gave them logical names that easily referred to their purposes. As we ran the program though, the tests simply didn’t run! We double-checked the syntax of our code, we asked for the TA’s help, and then out of despair, we even re-wrote the entire thing with a fresh start. But we still couldn’t pin it down. “What are we doing wrong?” Little did we know that a testing method in a subclass of unittest.TestCase had to start with the word ‘test’! In other word, the name of the method must be in the form testName, where “Name” is whatever you wish to call that function. This was especially fascinating to me because I never thought that a function’s name could have an effect on its running abilities!