How can you make sure that an app does exactly what it should do without any weird unexpected surprises? Well, you test it, of course. You could test everything manually by launching the app, using it, and trying your best to make the app blow up with errors. Or you can write a bunch of automated tests, which is arguably a more time-efficient and thorough way to test your apps. Let’s take a look at unit, widget, and integration tests in the video tutorial above.
Code snippets
VS Code snippets
{
"Basic test scaffolding": {
"prefix": "t_scaffold",
"body": [
"import 'package:flutter_test/flutter_test.dart';",
"",
"void main() {",
" late ${1:ClassName} sut;",
"",
" setUp(() {",
" sut = ${1:ClassName}();",
" });",
"",
" group('', () {});",
"}",
""
],
"description": "Basic test scaffolding"
}
"Test following the Arrange-Act-Assert pattern": {
"prefix": "aaaTest",
"body": ["test(", " \"$1\",", " () async {", " $2", " },", ");"],
"description": "Test following the Arrange-Act-Assert pattern"
},
}
nice snippet, thanks
Snippets for Android Studio:
For t_scaffold:
import ‘package:flutter_test/flutter_test.dart’;
void main() {
late $NAME$ sut;
setUp(() {
sut = $NAME$();
});
group(”, () {});
}
——-
For aaaTest:
test(
“$NAME$”,
() async{
$NAME1$
},
);
Very helpful
Thanks for sharing! ♥️