Software Development Methods and Tools—CSCI-3308

Lab 10—Unit testing

Objectives

Exercise

First, review the Python 3 unittest framework documentation.

Next, clone a copy of the Lab08-Files repository.

git clone https://github.com/lizboese/CU-CSCI3308-PythonUnitTesting

This repository includes a simple Python 3 module with a class called Processor that performs some basic analysis methods on the input text. Review the Lab08-Files for details.

The repository also contains the start of a Python 3 unittest file: textproc_test.py. Execute this file to confirm that the single, initial unit test passes.

Questions

Add the following tests to the textproc_test.py file:

  1. Write a test to verify the constructor raises an error if passed something other than a string
  2. Write one or more unit tests to test the count() method
  3. Write one or more unit tests to test the count_alpha() method
  4. Write one or more unit tests to test the count_numeric() method
  5. Write one or more unit tests to test the count_vowels() method
  6. Write one or more unit tests to test the is_phonenumber() method
  7. Find and correct any bugs the tests turn up

Credit

To get credit for this lab exercise, show the TA and sign the lab’s completion log.

Lab material by Liz Boese.