Skip to content

Instantly share code, notes, and snippets.

@rafdls
Last active January 9, 2020 05:03
Show Gist options
  • Save rafdls/75aaf2c363e5a1adc150b4884ec50f8d to your computer and use it in GitHub Desktop.
Save rafdls/75aaf2c363e5a1adc150b4884ec50f8d to your computer and use it in GitHub Desktop.
flutter unit test basics
import 'package:flutter_test/flutter_test.dart';
void main() {
group('This list of numbers', () {
List numberList = [1, 2, 3, 4, 5];
test('should have the right length', () {
expect(numberList.length, equals(5));
});
test('should have the correct order', () {
expect(numberList, orderedEquals([1, 2, 3, 4, 5]));
});
});
}
import 'package:flutter_test/flutter_test.dart';
void main() {
test('my first test', () {
expect(2, equals(2));
});
test('item should be in list', () {
expect([1, 2, 3, 4], contains(2));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment