Northcentral Technical College Introduction To Programming
10-152-310
Introduction to Programming with JavaScript NTC 10-152-310

Learning Plan 4 Test Plans

# Test Plans

#### File: /Learning Plan 4/testplans.html

> How do I know that my program works?

### What's the issue?

- Computer programs can get complicated with lots of different possible outcomes.
- It's not feasible to try all possibilities for data.
- How do we know that our programs work?
- The simple answer:
- Testing

### Test-driven Development

- Virtually all programming shops in the area use some variation of a technique called Test-driven Development or `TDD`.
- These employers want you to know what `TDD` means, how it works, and be ready to use it heavily.
- However, they don't expect you to be experts at it right out of school.
- What's `TDD`? Here's a short definition:
  - TDD is a computer programming technique involving writing test cases first; then, implementing just the code needed to pass the test. Test-driven development gives rapid feedback as part of an Extreme Programming methodology. TDD is not merely a method of testing: Adherents emphasize test-driven development as a method of designing software.
- Here's a larger description of it:
  - TDD on Wikipedia
- This semester we're going to start learning about testing software.

### Getting Started With Testing

- The basic idea of testing is that we need to identify some inputs and outputs that would indicate that our code is performing correctly.
- If our code is supposed to add two numbers together then we should be able to say something like this:
  - If I input the numbers `2` and `3`, the answer should be `5`.
- We can also confirm the answers with other means like a calculator.
- We'll make a list of these inputs and outputs, each one is called a Test Case.
- The list of test cases is called our Test Plan.
- Then we run our program with all the values in our test case.
- If all of our test cases come up with the right answers then we can say our tests have passed.
- If we don't get all the correct answers, then we know we have more work to do.

### Test Plans

- We're going to use simple test plans right in our labs and projects. Here's what they look like.

    TEST PLAN:

    Test Case 1:
        Inputs:

        Expected Results:

    Test Case 2:
        Inputs:

        Expected Results:

    Test Case 3:
        Inputs:

        Expected Results:

    Test Case 4:
        Inputs:

        Expected Results:

    Test Case 5:
        Inputs:

        Expected Results:

- From now on all of our projects and lots of labs and exercises will require a test plan. You will just fill in the data into a plan like the one above where one is asked for.