Thursday, 13 February 2014

Week 2 SLOG - Unittest

With the past couple of weeks being filled to the brim with midterms and projects, you can probably see that I have neglected my SLOG. I know. Terrible. However, what I did do was write down some notes on things I wanted to talk about, so today, tomorrow and the day after that I'm going to post a SLOG summarizing some of the things I wanted to talk about in my SLOG for the two weeks that I missed, plus a SLOG for this week.

Today, I will go back to the SLOG Week 2 version of me.

This week, I completed lab 3, which involved unittesting. This lab was a huge wakeup call for me. Although we'd briefly looked at unittesting in my past programming course, throughout the course of this lab I realized that I actually had no idea how it worked. My partner and I managed to make it through the lab with our limited knowledge of unittesting, but over the past week I've been starting to review how it really works. I don't quite have a grasp of it yet; it just doesn't seem intuitive to me. But each time I look at it, I feel like I understand a little more.

One thing I definitely understand about unittest now is its purpose. It makes testing easier by making it automatic. Instead of typing your test cases into the Python shell over and over again, you can type them once into unittest code and just run the code to test it. It also allows you to group test cases together, which can make your code more organized. Unittest uses the setUp() function to create an object to be tested. It then has a function for each test case, the names of which should describe what you're testing. Using the 'assert' keyword, you can test whether performing certain actions on the object returns the values you are expecting. For instance, you can use assertTrue to check whether the test object or an action performed on the test object returns true.

Hopefully as I continue to look at unittest, it will become more and more clear to me until I no longer have any trouble with it at all.

No comments:

Post a Comment