Aller au contenu principal
ProduitsOutils de bureauTASTECADConsultation de plansTASTEFILESGestion de fichiersTASTEFTPTransfert de fichiersTASTESSHEspace de travail à distanceTASTEZIPCompression et extractionOutils pour développeursTASTECODEEnvironnement de développement intégré pour RustTASTESTUDIOEnvironnement intégré de développement et de testTASTEETLIntégration de données (ETL)ServeursTASTEREMOTEServeur de bureau à distanceTASTEGEOServeur géospatialTASTEMAILEspace de travail e-mailCommencerTéléchargementsDocumentationAcheterTous les produits
Marketplace
Actualités
TechActualitésL’actu dev du jourDocs développeursLangages de programmationRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFrameworks front-end webNext.jsReactVue.js · NuxtSvelteKitAngularFrameworks serveurSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFrameworks d'applications et de bureauTauriFlutterReact NativeElectronAlgorithmesBases des algorithmesAlgorithmes essentielsAlgorithmes avancésAlgorithmes pratiques
CommunautéProjetsJournaux de développementPromptsProblèmes d’outils d’IAVitrineGuide de la communauté
CollaborerTransfert techniqueRéalisation de site webRéalisation d'application de bureauChaîne de publication et de paiementPartenaire commercialContact
ServicesBureau à distancePaquets d'installation sur mesure
TASTEDEV
Produits

Outils de bureau

TASTECADDes plans complexes, ouverts en toute légèretéTASTEFILESSeulement les fichiers utiles, au plus viteTASTEFTPLe chemin le plus net pour vos fichiersTASTESSHEntre vos serveurs et vous, un lien plus solideTASTEZIPCompresser plus vite, extraire en toute sécurité

Outils pour développeurs

TASTECODEModifier, compiler, déboguer et tester vos apps Rust dans une seule fenêtreTASTESTUDIODe l’édition aux tests à distance et aux corrections IA approuvéesTASTEETLDéplacer les données, les valeurs sous les yeux

Serveurs

TASTEREMOTEUn bureau à distance hébergé sur votre propre serveurTASTEGEOUn serveur géospatial compatible GeoServer, reconstruit en RustTASTEMAILReprenez la maîtrise de vos e-mails

Commencer

TéléchargementsDernières versions de chaque produitDocsUtiliser chaque produitAcheterAbonnements et licences perpétuellesTous les produitsTous les produits en un coup d’œil
Tous les produits
MarketplaceActualités
Tech

Actualités

L’actu dev du jourAnnonces officielles : langages, frameworks, GitHub et IADocs développeursGuides des langages, frameworks et algorithmes

Langages de programmation

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Frameworks front-end webNext.jsReactVue.js · NuxtSvelteKitAngular
Frameworks serveurSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Frameworks d'applications et de bureauTauriFlutterReact NativeElectron

Algorithmes

Bases des algorithmesAnalyse de complexité · Tri · Recherche · Structures de données de base · Arbres et tasAlgorithmes essentielsParcours de graphe · Plus courts chemins et arbres couvrants · Programmation dynamique · Algorithmes gloutons · Diviser pour régner · Backtracking (retour sur trace)Algorithmes avancésAlgorithmes sur les chaînes · Mathématiques et théorie des nombres · Manipulation de bits · Arbres de segments · Union-FindAlgorithmes pratiquesStratégie pour les entretiens de codage · Cache LRU · Limitation de débit · Hachage cohérent
Toute la documentation de développement
Communauté
ProjetsDécouvrir les créateurs et leurs travauxJournaux de développementDécisions et enseignementsPromptsInstructions réutilisablesProblèmes d’outils d’IAProblèmes et contournements de Claude, Codex, GeminiVitrineRéalisations terminéesGuide de la communautéConstruire en toute transparence
Collaborer
Transfert techniqueApplications natives en Rust et eguiRéalisation de site web10 langues, comptes, documentation et téléchargementsRéalisation d'application de bureauRust et egui, sans WebViewChaîne de publication et de paiementSignature, MSI, deb, rpm, AppImage, empreintesPartenaire commercialRecommandez-nous, touchez 30 %ContactDéveloppement, partenariats, investissement
Services
Bureau à distanceAccédez à votre ordinateur depuis le navigateurPaquets d'installation sur mesureSeulement l'utile, réglages préchargés
Acheter
FR
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Se connecter
Se connecter
TASTEDEV

Des petits outils à un meilleur développement.

support@tastedev.netSoutenir TASTEDEV
ProduitsGamme de produitsAcheterDocsTéléchargementsMarketplaceAssistance
CommunautéProjetsJournaux de développementPromptsProblèmes d’outils d’IAVitrine
RèglesPolitique de confidentialitéConditions d'utilisationConditions d’abonnementRemboursementRègles de la communauté
CompteSe connecterS'inscrire
Visiteurs
Aujourd’hui
012345678901234567890123456789012345678901234567890123456789
Hier
012345678901234567890123456789012345678901234567890123456789
Vues au total
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Société
GXSOFT
Représentant
CHOI YOUNG GU
Numéro d’enregistrement
853-44-00368
Adresse
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Téléphone
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsable de la confidentialité
CHOI YOUNG GU

© 2026 TASTEDEVLes informations produit s'appuient sur des sources de développement vérifiées.Publié · en amélioration

Documentation Flutter
Flutter
Getting Started with FlutterProject StructureCore ConceptsData and StateTestingBuilding and Deployment
Discussions

Guide Flutter · 5/6

Testing

Ce chapitre n'est disponible qu'en anglais pour le moment.

Flutter ships its testing tools with the SDK. Tests fall into three groups by scope: unit tests check a single function or class, widget tests check a widget or a small part of a screen, and integration tests run the whole app on a real device or emulator. The broader the test, the more realistic and the slower it is, so write many unit and widget tests and keep integration tests for critical flows.

KindScopeRuns onSpeed
Unit testFunctions, classes, state logicDart VMVery fast
Widget testWidgets, parts of screensSimulated test environmentFast
Integration testFull app flowsDevice, emulator or desktopSlow

Unit tests

Put test files in the test folder and end their names with _test.dart. In Flutter projects, the flutter_test package also provides test, group and expect.

// lib/cart.dart
class Cart {
  final Map<String, int> _prices = {};

  void add(String name, int price) => _prices[name] = price;
  int get total => _prices.values.fold(0, (sum, price) => sum + price);
}
// test/cart_test.dart
import 'package:flutter_test/flutter_test.dart';
import 'package:hello_app/cart.dart';

void main() {
  group('Cart', () {
    test('starts with a total of 0', () {
      expect(Cart().total, 0);
    });

    test('adding items increases the total', () {
      final cart = Cart()
        ..add('apple', 1000)
        ..add('pear', 2500);
      expect(cart.total, 3500);
    });
  });
}

Run tests from the command line or your editor:

# Run all tests
flutter test

# Run a single file
flutter test test/cart_test.dart

# Run tests whose name matches
flutter test --name "total"

# Collect coverage (writes coverage/lcov.info)
flutter test --coverage

Widget tests

Widget tests use testWidgets. The WidgetTester mounts a widget (pumpWidget), finds things (find), interacts (tap), rebuilds (pump) and then you assert. The generated test/widget_test.dart is exactly this kind of test:

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hello_app/main.dart';

void main() {
  testWidgets('tapping add increments the counter', (WidgetTester tester) async {
    await tester.pumpWidget(const MyApp());

    expect(find.text('0'), findsOneWidget);
    expect(find.text('1'), findsNothing);

    await tester.tap(find.byIcon(Icons.add));
    await tester.pump();

    expect(find.text('0'), findsNothing);
    expect(find.text('1'), findsOneWidget);
  });
}
Des questions sur ce chapitre ?
Chapitre précédentData and StateChapitre suivantBuilding and Deployment

Commonly used helpers:

  • find.text, find.byType, find.byIcon, find.byKey: locate widgets. Giving widgets a key such as Key('submit') makes them easy to find.
  • findsOneWidget, findsNothing, findsNWidgets(n): check how many were found
  • tester.enterText(finder, 'text'): type into a text field
  • tester.pumpAndSettle(): keep pumping frames until animations finish

Replacing dependencies

When testing code that hits the network, use fake responses instead of a real server. The http package includes a MockClient for tests, so if your function accepts an http.Client, swapping it is easy. For more complex cases, create fakes with mocktail or mockito.

import 'package:http/http.dart' as http;
import 'package:http/testing.dart';
import 'package:flutter_test/flutter_test.dart';

Future<String> fetchTitle(http.Client client) async {
  final response = await client.get(Uri.parse('https://example.com/title'));
  return response.body;
}

void main() {
  test('returns the response body', () async {
    final client = MockClient((request) async => http.Response('Flutter', 200));
    expect(await fetchTitle(client), 'Flutter');
  });
}

Integration tests

Integration tests use the integration_test package that comes with the SDK. They launch the app on a real device, emulator or desktop and drive it with the same API as widget tests. First add the dev dependency:

flutter pub add 'dev:integration_test:{"sdk":"flutter"}'

Place test files in an integration_test folder at the project root:

// integration_test/app_test.dart
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:hello_app/main.dart' as app;

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  testWidgets('full app flow', (tester) async {
    app.main();
    await tester.pumpAndSettle();

    await tester.tap(find.byIcon(Icons.add));
    await tester.pumpAndSettle();

    expect(find.text('1'), findsOneWidget);
  });
}
# Run on a connected device
flutter test integration_test/app_test.dart

# Pick a device
flutter test integration_test -d windows

Summary

  • Unit tests cover logic, widget tests cover UI behavior, and integration tests cover the whole app on a real device.
  • Run every kind with flutter test, and add --coverage to collect coverage.
  • Widget tests follow the pattern pumpWidget, find, tap, pump, expect.
  • Design code so external dependencies come in through constructors or parameters and can be replaced with fakes.

0 commentaire

Meilleurs commentairesPlus récents d'abord

Se connecter · Connectez-vous pour laisser un commentaire.