1 of 18

Testing & Static Analysis

Fall 2025

1

2 of 18

Announcements

  1. We will be starting on Project 1 in class next week – it will be due in a few weeks (after the midterm).
  2. The midterm exam will be the Thursday after Fall Break
  3. Today’s readings: Testing!
  4. Lab 5 due tomorrow night
  5. Lab 6 (Testing Lab): in class Thursday

3 of 18

Today’s Agenda

  1. Testing Overview
  2. Static Analysis Preview
  3. Activity: Testing & Static Analysis

3

4 of 18

Today’s Agenda

  1. Testing Overview
  2. Static Analysis Preview
  3. Activity: Python practice

4

5 of 18

Testing: Discussion Questions

Some testing questions you should be able to answer by the end of this unit:

  1. What are some of the benefits of automated testing?
  2. What are some of the challenges or limits of automated testing?
  3. What are the different test "sizes"? Why are these distinctions important?
  4. What is meant by "nondeterminism" in testing?
  5. What are some important qualities of a testing suite?
  6. What are some considerations that go into writing testable code?

6 of 18

What is a test?

  • A single behavior you are testing
  • A specific input, some value that you pass to the API
  • An observable output or behavior
  • A controlled environment such as a single isolated process

�“Taken in aggregate, hundreds or thousands of simple tests (usually called a test suite) can tell you how well your entire product conforms to its intended design and, more important, when it doesn’t.”

7 of 18

A bit of Google history…

  • What was the story of the Google Web Server?
  • What is the Beyonce Rule?
  • What is “Testing on the Toilet”?

8 of 18

What are some of the benefits of automated testing?

  • Running the tests if fast – “Did it break something else”?
    • Delegate the checks to the bot (go get some coffee)
  • The more test coverage, the better.
  • Confidence
  • Consistency – tests are the same for every developer
  • Saves money! – The earlier that you catch errors, the faster and cheaper you can do thing.
  • A form of documentation
  • Better code – you think more about edge cases, input and output.

9 of 18

What are some of the benefits of automated testing?

Other things:

  • Less debugging
  • Increased confidence in changes – Why?
  • Improved documentation – Why?
  • Simpler reviews – Why?
  • Thoughtful design – Why?
  • Fast, high-quality releases – Why?

10 of 18

What are the challenges / limits of automated testing?

  • Time constraints…
  • Initially, labor intensive
  • Might be overkill if you’re writing something small.
  • Steep learning curve
  • Maintainence

11 of 18

What are the different test "sizes"?

  • Small tests – 80%
    • 1 process, doesn’t call IO no files, no DB, no cloud, etc.
    • Unit tests
  • Medium –15%
    • Multithreaded
    • Connecting to an API.
  • Large – 5%
    • What does this mean?

12 of 18

What does it mean to write code so that it is testable?

Should be modular, isolated, and follows good design principles:

1. Single Responsibility Principle (SRP)

2. Separation of Concerns

3. Avoiding Side Effects

4. Dependencies are arguments instead of hardcoding.

13 of 18

Today’s Agenda

  1. Testing Overview
  2. Static Analysis Preview
  3. Activity: Testing & Static Analysis

13

14 of 18

Static Analysis

  • What is a Compiler?
  • What languages are compiled?
  • Do JavaScript and Python have compilers?
  • What is an Interpreted Language?

15 of 18

Static Analysis

Static-Analysis

  • Uses tools to examine and evaluate code without actually running it

Autoformatters

  • Focuses on formatting code automatically, enforcing style consistency (e.g., Black)

Linters

  • Focuses on analyzing code for possible errors, style violations, or inefficiencies, but typically leaves the code unchanged (e.g., Flake8)

16 of 18

Today’s Agenda

  1. Testing Overview
  2. Static Analysis Preview
  3. Activity: Python

16

17 of 18

Python Exercise

Given that Project 1 and 2 will be written in Python, let’s practice our skills!

  • Inside of your csci338 folder, create a folder called python_practice
  • Inside of python_practice, create a file called exercises.py, where you will write the answers to the challenge problems.
    • You can also create multiple files to organize your code (optional).
  • Only use a GenAI tool as a last resort

Important: You should be able to solve problems like these on the Midterm Exam (by hand).

18 of 18

See you Thursday!