Skip to content

pedrostick3/flutter_tests

Repository files navigation

flutter_tests

A Flutter Proof of Concept for Unit, Widget, and Integration Testing.

📺 Tutorial

Watch the full walkthrough: YouTube Tutorial


🗂️ Project Structure

flutter_tests/
├── lib/
│   ├── main.dart
│   └── user.dart
├── test/
│   ├── user_unit_test.dart      # Unit tests
│   └── widget_test.dart         # Widget tests
├── test_integration/
│   └── app_test.dart            # Integration tests
└── README.md

🧪 Running Tests

1. Unit Tests

  • Location: test/user_unit_test.dart
  • How to run:
    • Open the file in VS Code and click the "Run" button above the test.
    • Or run in terminal:
      flutter test test/user_unit_test.dart

2. Widget Tests

  • Location: test/widget_test.dart
  • How to run:
    • Open the file in VS Code and click the "Run" button above the test.
    • Or run in terminal:
      flutter test test/widget_test.dart

3. Integration Tests

  • Location: test_integration/app_test.dart
  • How to run:
    • Note: Integration tests do not appear in the VS Code "Testing" tab.
    • Run in terminal:
      flutter test test_integration/app_test.dart
    • OR, Run test_integration/app_test.dart file with the desired device on VS Code.

🧑‍💻 Tips for Junior Developers

  • Test Types:

    • Unit tests check individual classes/functions.
    • Widget tests verify UI components in isolation.
    • Integration tests simulate real user flows across the app.
  • VS Code Testing Tab:

    • Only unit and widget tests in the test/ folder appear here.
    • Integration tests must be run from the terminal.
  • Best Practices:

    • Write clear, descriptive test names.
    • Keep tests small and focused.
    • Run tests frequently during development.
  • Troubleshooting:

    • If a test fails, read the error message carefully.
    • Make sure your emulator/device is running for integration tests.
    • If you encounter permission errors on Windows, try running your terminal as administrator or move your project to a shorter path (e.g., C:\flutter_tests).

📚 Further Reading


Happy coding!

About

Flutter APP with multiple test types

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors