Course site

TE 7 - Implement Automated Testing

In this team exercise, you will add automated tests to your project. Your tests should verify important behavior at multiple levels of the application:

The goal is not simply to increase the number of tests. Your team should select meaningful behavior, define expected outcomes, and create tests that help prevent regressions as your project changes.

Learning Objectives

After completing this exercise, your team should be able to:

Required Testing Levels

Part I: Test-Driven Development

Use TDD to implement or improve one meaningful feature, validation rule, or bug fix for small feature/issue.

Follow the Red–Green–Refactor cycle:

  1. Red: Write a test that describes the expected behavior. Confirm that it fails.
  2. Green: Write the smallest amount of production code needed to make the test pass.
  3. Refactor: Improve the code structure while keeping all tests passing.

Document the TDD process in your README or testing document. Include:

Part II: Unit Testing

Unit tests verify a small unit of code in isolation, such as a function, class, service method, or validation rule.

Your team must create at least four unit tests covering at least two different units of code.

Good unit-test targets include:

Part III: System Testing

For this assignment, a system test verifies that multiple parts of your application work together to complete a feature. For example, a system test may exercise an API endpoint, its service logic, and its data-access layer. At a minimum, it tests two functions/methods that make up one feature.

Your team must create at least two system tests.

Examples:

Part IV: UI Testing

UI tests verify that a person can complete an important task through the interface.

Your team must create at least two UI tests covering at least one complete user story.

Examples:

UI tests should verify what the user can see or do. Avoid testing implementation details such as a component’s internal state.

Note: For groups using react native, the UI testing can be component-level tests (React Testing Library).

Test Tools

Select tools that fit your project’s technology stack. Common options include:

Testing Level Possible Tools
Unit and system testing Jest, Vitest, Mocha, Supertest
React UI testing React Testing Library with Jest or Vitest
Browser-based UI testing Playwright or Cypress

Your team may use different tools if they are appropriate for your technology stack.

Test Scripts

Configure your project so the test suite can be run from the command line.

At minimum, your project package.json should provide:

{
  "scripts": {
    "test": "your-test-command"
  }
}

If you use a monorepo, document the command required to run tests for each workspace. Examples: npm test npm run -w express-backend test npm run -w react-frontend test

Documentation Requirements

Add a TESTING.md file or a Testing section in your project README. Include:

  1. The testing tools your team selected for each type of test.
  2. Instructions for installing dependencies and running tests.
  3. A short description of each required testing level.
  4. The feature, rule, or bug fix developed using TDD.
  5. Any external services, environment variables, seed data, or test databases required.
  6. Known testing limitations or future tests your team would add.

Turning It In

Submit the URL for your team’s GitHub repository to the Canvas assignment. Your repository must include:

Only one submission per team is required.