title: Flutter Integration testing failed for multiple test cases in a single file
body: <p>I have a simple login page with email and password text field. A button to login and another to sign up. I tried to write integration testing for the Sign in page.</p>
  <pre><code>void main() {
    IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  
    testWidgets('''could type email and password in text filed''',
        (WidgetTester tester) async {
      await app.main();
      await tester.pumpAndSettle();
  
      final textFieldEmail = find.byType(InputTextWidget).first;
      final textFieldPassword = find.byType(InputTextWidget).last;
  
      await tester.enterText(textFieldEmail, &quot;asis.adh@gmail.com&quot;);
      await tester.pumpAndSettle();
  
      expect(find.text(&quot;asis.adh@gmail.com&quot;), findsOneWidget);
    });
  
  testWidgets(
        'should redirect to Sign Up Page when create an account is tapped',
        (WidgetTester tester) async {
      await app.main();
      await tester.pumpAndSettle();
  
      final createAnAccount = find.text(&quot;Create an account&quot;);
      await tester.tap(createAnAccount);
  
      await tester.pumpAndSettle();
  
      expect(find.byType(SignupPage), findsOneWidget);
      expect(find.byType(LoginPage), findsNothing);
    });
  }
  </code></pre>
  <p>When I execute the test case, it fails with the following error:</p>
  <blockquote>
  <p>The following ArgumentError was thrown running a test: Invalid
  argument(s): Object/factory with  type AmenitiesProvider is already
  registered inside GetIt.</p>
  </blockquote>
  <p>Here is my <code>main.dart</code> file</p>
  <pre><code>Future main() async {
    WidgetsFlutterBinding.ensureInitialized();
    configureInjection(Environment.prod);
  
    /// for registering the factory.
    await Future.delayed(const Duration(seconds: 2));
    runApp(RoopaApp());
  }
  </code></pre>
  <p>I tried with a <code>main_test.dart</code> and adding <code>configureInjection(Environment.test)</code> but nothing changes. I am not sure how to fix the error. Is there a way to clean the <code>app</code> or destroy it before going to new test case. If I combine the both testcase into one then it works without any problem.</p>
  <p>Here is <code>configureInjection</code></p>
  <pre><code>@injectableInit
  void configureInjection(String environment) {
    $initGetIt(getIt, environment: environment);
  }
  </code></pre>
  <p>I am using get_it and injection package for dependency injection.</p>
  <p>Here is the auto generated initGetIt</p>
  <pre><code>GetIt $initGetIt(
    GetIt get, {
    String environment,
    EnvironmentFilter environmentFilter,
  }) {
    final gh = GetItHelper(get, environment, environmentFilter);
    final httpClientInjectableModule = _$HttpClientInjectableModule();
    final flutterStorageModule = _$FlutterStorageModule();
    gh.lazySingleton&lt;AmenitiesProvider&gt;(() =&gt; AmenitiesProvider());
    gh.factory&lt;Client&gt;(() =&gt; httpClientInjectableModule.client);
    gh.lazySingleton&lt;FileProvider&gt;(() =&gt; FileProvider());
    gh.lazySingleton&lt;FlutterSecureStorage&gt;(
        () =&gt; flutterStorageModule.secureStorate);
    gh.factory&lt;ProfilePageBloc&gt;(() =&gt; ProfilePageBloc());
    gh.factory&lt;SplashScreenBloc&gt;(() =&gt; SplashScreenBloc());
    gh.lazySingleton&lt;AuthLocalDataSourceProtocol&gt;(
        () =&gt; AuthLocalDataSource(secureStorage: get&lt;FlutterSecureStorage&gt;()));
    gh.lazySingleton&lt;AuthRemoteDataSourceProtocol&gt;(
        () =&gt; AuthRemoteDataSource(client: get&lt;Client&gt;()));
    return get;
  }
  </code></pre>