Tuesday, 31 March 2015

Week 10: Testing Code

Ah, testing. I know it's terrible of me but I'm lazy with testing. I know it's a crucial part of creating beautiful and functional code but I'm always tired after creating functional code, especially during a time crunch. Proper testing will see if your code is able to break in the near infinite variations of applications that it's put through so it's very clear why it's important. You definitely want it to work in as many different situations as possible. Testing is doubly important when it comes to actual work submissions!

    Unittests in Python are the best way to implement test scenarios. It's built into Python and easily accessible with a bit of code. Unittests were a part of 108 but not a heavy part of 148, which is why I haven't gotten too used to them yet. We learned some new ways to implement unittests this week: the setup and teardown methods. Setup is used to prepare the test case, create any starting variables necessary for the function to work (e.g. setting up gamestates). Teardown is used to destroy the test case after setting it up to start a fresh case.

    I shall try my best to get into the habit of testing my code!

No comments:

Post a Comment