I am a beginer in flutter and I have to write some unit test for a project but I get an error and can't find the solution to solve it.
Here is the function that I want to test:
addUser(name, password) async{
if (name.toString().isEmpty || password.toString().isEmpty) {
return "Error";
}
return await dio.post('https://test.test.com/adduser',
data: {"name": name, "password": password},
options: Options(contentType: Headers.formUrlEncodedContentType));
}
Here is the test code:
void main() {
test('Empty field', () {
var auth = AuthService();
String result = auth.addUser("", "");
expect(result, "Error");
});
}
And I get this error:
type 'Future<dynamic>' is not a subtype of type 'String'
test\widget_test.dart 17:18 main.<fn>
Can someone help to find where I made a mistake please ? Thanks for yours answers.