Day 8: Thursday, January 30th, 2014

  1. Read the links from Day 7: Tuesday, January 28th, 2014: http://www.fastcompany.com/28121/they-write-right-stuff and http://www.infoworld.com/print/15243; skim http://calleam.com/WTPF/?page_id=2086
  2. Quiz and discussion.
  3. Lecture on code coverage and code paths: presentation
  4. Code review and code coverage of hw3

I’m happy to help with any git problems you have, also.

Computing and displaying code coverage stats

First, activate your virtualenv (see Using virtualenv). Then install coverage:

pip install -U coverage

(You may want to reactivate your virtualenv after installing this; I’ve had some path problems.)

Next, grab some code to run it on – let’s use the ‘hw2-solutions’ branch from https://github.com/ctb/cse491-serverz.

mkdir ~/cse491
cd ~/cse491
git clone https://github.com/ctb/cse491-serverz.git -b hw2-solutions day8

Run the tests with code coverage enabled:

cd day8
nosetests --with-coverage

Generate HTML output of your code coverage:

coverage html

which will put it in the directory ‘htmlcov’, and then post it to your arctic Web site:

mkdir ~/web/
cp -r htmlcov ~/web/day8-htmlcov
chmod -R a+rx ~/web/

Now go to http://www.cse.msu.edu/~$username/day8-htmlcov/ to look at the code coverage report – mine is here:

If you look at ‘server.py’, you’ll see some covered stuff (green) and some uncovered stuff (red):

Why? Can you think of any way to “cover” the red stuff in the tests?

Things to try

Run code coverage on your own hw3. What did you fail to test in server.py?

Deactivate some of your tests by putting a ‘return’ right after the start of the function. Does the code coverage change in the expected way?

Do a review of someone else’s hw3, and either make comments on their pull request or on their code directly (by checking it out locally). Note, you can grab someone’s code by doing something like this, in an existing repo:

git fetch https://github.com/ctb/cse491-serverz hw3 ctb-hw3
git checkout ctb-hw3

If you make changes, comments, etc. then you can share them by first committing them, and then doing:

git push origin ctb-hw3:ctb-hw3

and setting up a pull request between YOUR copy of their branch (here, ctb-hw3 in your github repo) and THEIR hw3 branch.

If you use coverage analysis during your review, you might be able to find untested logic – and there might be bugs in there, too. Try writing a test that breaks their code (or at least covers it).

Code review checklist

Basic rules:

  1. Does it run.
  2. Do tests pass.
  3. Spaces rather than tabs.
  4. Spaces after #.
  5. Properly spelled variable names .
  6. Try writing tests to break something. For example, do you believe their POST logic?
  7. 80 character line lengths.
  8. Test with multiple browsers.
  9. Use code coverage to find things that their tests don’t test, and see if you can break their code.

List of repositories

massiek: github site - pulls - branches - repo URL for cloning

eunbong: github site - pulls - branches - repo URL for cloning

matheusldaraujo: github site - pulls - branches - repo URL for cloning

ConnorAvery: github site - pulls - branches - repo URL for cloning

jprickles: github site - pulls - branches - repo URL for cloning

jkteuber: github site - pulls - branches - repo URL for cloning

beckhamer: github site - pulls - branches - repo URL for cloning

john3209: github site - pulls - branches - repo URL for cloning

mill1256: github site - pulls - branches - repo URL for cloning

YourBestFriend: github site - pulls - branches - repo URL for cloning

hoffm386: github site - pulls - branches - repo URL for cloning

joshshadik: github site - pulls - branches - repo URL for cloning

msweet18: github site - pulls - branches - repo URL for cloning

juru13: github site - pulls - branches - repo URL for cloning

mcdonaldca: github site - pulls - branches - repo URL for cloning

filajust: github site - pulls - branches - repo URL for cloning

leflerja: github site - pulls - branches - repo URL for cloning

FireSBurnsmuP: github site - pulls - branches - repo URL for cloning

koppmana: github site - pulls - branches - repo URL for cloning

Karmeow: github site - pulls - branches - repo URL for cloning

curljosh: github site - pulls - branches - repo URL for cloning

yispencer: github site - pulls - branches - repo URL for cloning

glisto18: github site - pulls - branches - repo URL for cloning

mannin92: github site - pulls - branches - repo URL for cloning

westjour: github site - pulls - branches - repo URL for cloning

jbull477: github site - pulls - branches - repo URL for cloning

fakestuff: github site - pulls - branches - repo URL for cloning

msu-web-dev: github site - pulls - branches - repo URL for cloning

MaxwellGBrown: github site - pulls - branches - repo URL for cloning

xavierdhjr: github site - pulls - branches - repo URL for cloning

ettemaet: github site - pulls - branches - repo URL for cloning

lieblic2: github site - pulls - branches - repo URL for cloning

bjurgess1: github site - pulls - branches - repo URL for cloning

suhkang: github site - pulls - branches - repo URL for cloning

jonest31: github site - pulls - branches - repo URL for cloning

tsloncz: github site - pulls - branches - repo URL for cloning

zhopping: github site - pulls - branches - repo URL for cloning

MattyAyOh: github site - pulls - branches - repo URL for cloning

o2themar: github site - pulls - branches - repo URL for cloning

phammin1: github site - pulls - branches - repo URL for cloning

Badsauce: github site - pulls - branches - repo URL for cloning

DuncanCYoung: github site - pulls - branches - repo URL for cloning

cameronkeif: github site - pulls - branches - repo URL for cloning

majeedus: github site - pulls - branches - repo URL for cloning

polavar3: github site - pulls - branches - repo URL for cloning

brtaylor92: github site - pulls - branches - repo URL for cloning

labrenzm: github site - pulls - branches - repo URL for cloning

QSSS: github site - pulls - branches - repo URL for cloning

sarteleb: github site - pulls - branches - repo URL for cloning

JRucinski: github site - pulls - branches - repo URL for cloning

fenderic: github site - pulls - branches - repo URL for cloning

Table Of Contents

Previous topic

Homework 4

Next topic

Day 7: Tuesday, January 28th, 2014

This Page

Edit this document!

This file can be edited directly through the Web. Anyone can update and fix errors in this document with few clicks -- no downloads needed.

  1. Go to Day 8: Thursday, January 30th, 2014 on GitHub.
  2. Edit files using GitHub's text editor in your web browser (see the 'Edit' tab on the top right of the file)
  3. Fill in the Commit message text box at the bottom of the page describing why you made the changes. Press the Propose file change button next to it when done.
  4. Then click Send a pull request.
  5. Your changes are now queued for review under the project's Pull requests tab on GitHub!

For an introduction to the documentation format please see the reST primer.