Last active
April 29, 2021 01:50
-
-
Save enzodanjour/02d1f7b25abe95c0ed9e09dfceed2bc8 to your computer and use it in GitHub Desktop.
Flutter unit test example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter_test/flutter_test.dart'; | |
| main() { | |
| //Arrange | |
| //inicialização do código | |
| HomeController controller; | |
| setUp(() { | |
| controller = HomeController(); | |
| }); | |
| // group a conjunct of tests | |
| group("Home Controller tests", () { | |
| test("Post initial value is null", () { | |
| //Assert, observação | |
| expect(controller.posts.value, isNull); | |
| //se as condições corresponderem, o teste foi aprovado | |
| //if condictions match, the test has been passed. | |
| }); | |
| test("Initial Posts size it's ok", () { | |
| //Act, execução | |
| await controller.getPosts(); | |
| final posts = controller.posts.value; | |
| //Assert, observação | |
| expect(posts.length, 3); | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment