'UI Automator - Avoiding the App closing at the end of the test

I've just started to work with UI Automator to make integration tests for my Android App, and I'm experiencing this problem:

After I've performed a test, the app closes, but I would like to keep it opened.

That's my code:

 @RunWith(AndroidJUnit4::class)
 class ExampleInstrumentedTest {

     private lateinit var device: UiDevice;
     @Test
     fun pressVediLogButton() {
         device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
         // Start from the home screen
         device.pressHome();

         val appButton = device.findObject(UiSelector().text("WINDTRE"))
         appButton.clickAndWaitForNewWindow()
     }
}

What should I write to "remain in the app"?

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source