Motivation

I’m coming up on week two of my side hustle to build a web application for my bro (I’ll call him the “client”). Time sure flies when someone pays you to do a job! A little about me…I’m a hobbyist developer. At work I’m a systems engineer involved with all sorts of things from gathering customer needs, developing concepts of operation, and architectural designs. I work closely with the development team to implement solutions but I’m not in the trenches cranking out code.

“Well-well look. I already told you: I deal with the goddamn customers so the engineers don’t have to! I have people skills; I am good at dealing with people. Can’t you understand that? What the hell is wrong with you people?” -Tom Smykowski from Office Space

I’d always heard management expound on the importance of unit testing and trying to get to a point where we’re doing Test-Driven Development but it wasn’t my job to make it happen. As I started tweaking with code for this project I thought now would be a good time to put unit testing to use so I wouldn’t have to worry about wrecking things. Especially since most of the time I was working on this after finishing my day job and putting the kids to bed.

So I got to click-clacking…

What Should I Write Unit Tests For?

I sat down at my keyboard and didn’t know where to start. At my day job, I’d only done end-to-end testing focused on the customer’s typical workflows. I understood the concept of unit tests and had been through some examples but I still had writer’s block. I recalled from work that the development team regularly talked about code coverage so I thought to myself “ok, let’s start there”.

Installing Coverage.py

As I do for everything in life, I went to Google to find what was out there for “python code coverage”. The top result was Coverage.py so I went about taking it for a test drive.

  1. Open the Terminal from inside PyCharm (View → Tool Windows → Terminal).
  2. Install it using pip
(myenv) $ pip install coverage

#unit-testing #python #web-development #testing #python-programming

Unit Testing and Code Coverage with PyCharm
2.55 GEEK