com_dromzee_flutter_testing
A tutorial for flutter testing
#tuto #flutter #dart #testing
Steps
Create Github repo
Open projet localy
git clone git@github.com:DROMZEE/com_dromzee_flutter_testing.git
cd com_dromzee_flutter_testing
code .
Edit .gitignore
- https://www.toptal.com/developers/gitignore/
- https://www.toptal.com/developers/gitignore/api/flutter,dart,git,visualstudiocode
Créer le projet flutter
flutter create com_dromzee_flutter_testing
flutter run
Modifier la fonction counter
Pour que le compteur change de couleur :
- vert si c'est un nombre pair
- orange si c'est un nombre impair
créer le fichier counter.dart
class Counter {
int number = 0;
Counter();
increment() {
number = number + 1;
}
Color setColor() => (number.isEven) ? Colors.green : Colors.deepOrange;
}
adapter le code de main.dart
Ajouter le test pour counter.dart
test('Test init', () {
Counter counter = Counter();
expect(counter.number, 0);
expect(counter.setColor(), Colors.green);
Lancer les tests
cliquer sur la fleche verte dans le code
CMD
flutter doctor
flutter upgrade
flutter clean
flutter analyze
flutter test
About me
Liens
- documentation Flutter sur les tests unitaires https://docs.flutter.dev/cookbook/testing/unit/introduction
Liens Flutter
-
Edouard Marquez
-
Driss AS
-
Maxime Britto - Purple Giraffe
-
Nicolas MORICET
-
CodApps
-
David Silvera
- Youtube David Silvera
-
Johannes Milke
-
Flutter
- Youtube Flutter