Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter test fails. compiler error getter not found 'main'

I'm trying to run flutter test using the terminal and i receive the following error. the following file C:/Users/User/AppData/Local/Temp/flutter_test_listener.e6fa92b4-6cd1-11e9-b9cb-68f728ca4610/listener.dart doesn't exist in the directory specified.

here's the error:

Compiler message: file:///C:/Users/User-45/AppData/Local/Temp/flutter_test_listener.e6fa92b4-6cd1-11e9-b9cb-68f728ca4610/listener.dart:46:17:

Error:Getter not found: 'main'. return test.main;

my project's directory is in another folder. how can i solve this? Thank you

like image 459
Salma Avatar asked May 02 '19 12:05

Salma


2 Answers

In my case, it happened that one of my helper classes in the test folder, had a name that ended "_test", and the compiler was looking for a main method. So I renamed the helper class, and problem solved.

like image 96
Rowan Gontier Avatar answered Sep 17 '22 07:09

Rowan Gontier


If anybody faces the above problem then try to add main() in test class and if you have added then remove it out of test class curly braces. I faced this and removed the main() out of test class.

Eg...

class GetConcreteNumberTrivia_Test extends Mock
    implements NumberTriviaRepository {}

void main() {

.....my implementation......
}
like image 24
vivek s Avatar answered Sep 21 '22 07:09

vivek s