Example for Unit Test (#52)

This commit is contained in:
Miten Gajjar
2020-07-06 00:12:20 +05:30
committed by GitHub
parent 07b7411e54
commit 389623e159
75 changed files with 1723 additions and 0 deletions

View File

@ -0,0 +1,58 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:unit_testing/helpers.dart';
void main() {
group(
'Email test',
() {
test(
'Valid Email test',
() {
final result = FormValidator.validateEmail("example@flutter.com");
expect(result, isNull);
},
);
test(
'Invalid Email test',
() {
final result = FormValidator.validateEmail("abcf");
expect(result, 'please enter valid email');
},
);
test(
'Empty email test',
() {
final result = FormValidator.validateEmail("");
expect(result, 'please enter email');
},
);
},
);
group(
'Password Test',
() {
test(
'Empty password test',
() {
final resutl = FormValidator.validatePassword("");
expect(resutl, 'please enter your password');
},
);
test(
'Valid password test',
() {
final resutl = FormValidator.validatePassword("hello@123456");
expect(resutl, isNull);
},
);
test(
'Invalid password test',
() {
final resutl = FormValidator.validatePassword("hello");
expect(resutl, 'minimum lenght of password must be 8 characters');
},
);
},
);
}