# Android app restarts after each test case

**URL:** <https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927>\
**Category:** Mobile Testing\
**Tags:** mobile-testing, katalon-studio\
**Created:** [January 18, 2018, 11:02am UTC](https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927 "2018-01-18T11:02:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robin](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@Robin](https://forum.katalon.com/u/Robin)\
**Post date:** [January 18, 2018, 11:02am UTC](https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927/1 "2018-01-18T11:02:46Z")

</div>

Hi, i am using Katalon to test a few native Android apps and until a few Katalon versions ago it was working perfectly fine.

The issue i am experiencing: Every time i try to run a test suite it will restart the application on my real android device, it did not do this before in old Katalon versions. The android app needs to load allot of data from different servers before it’s fully started which usually takes up close to 40 seconds..

Restarting the app after each test case renders the whole automation useless for me.. is there any way to stop restart the app after each test case when executing a test suite?

\* returning to an old katalon version does not resolve the issue.  
\* unchecking the terminate drivers after each test case in the default project execution settings does not help

---

<div class="post-metadata">

**Author:** ![Zarashima](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/zarashima/32/928_2.png) [@Zarashima](https://forum.katalon.com/u/Zarashima)\
**Post date:** [January 18, 2018, 11:14am UTC](https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927/2 "2018-01-18T11:14:16Z")

</div>

Which Appium and Android version you are using?

---

<div class="post-metadata">

**Author:** ![Zarashima](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/zarashima/32/928_2.png) [@Zarashima](https://forum.katalon.com/u/Zarashima)\
**Post date:** [January 18, 2018, 11:24am UTC](https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927/3 "2018-01-18T11:24:16Z")

</div>

Based on this article: [appium/reset-strategies.md at master · appium/appium · GitHub](https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/other/reset-strategies.md), you can try to use noReset instead:  
 ![](https://s3.amazonaws.com/katalon-forum/editor/yj/53qldvt6x1s9.png "Image: https://s3.amazonaws.com/katalon-forum/editor/yj/53qldvt6x1s9.png")

[Screen Shot 2018-01-18 at 18.21.38.png](https://s3.amazonaws.com/katalon-forum/editor/yj/53qldvt6x1s9.png)

---

<div class="post-metadata">

**Author:** ![Mohammad\_Mosaj\_Gohar](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mohammad_mosaj_gohar/32/16104_2.png) [@Mohammad\_Mosaj\_Gohar](https://forum.katalon.com/u/Mohammad_Mosaj_Gohar)\
**Post date:** [January 20, 2018, 3:54pm UTC](https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927/4 "2018-01-20T15:54:39Z")

</div>

Hi Robin,  
the first test step in your recording would be “start the application”. change the value to “false” from true for the param “UninstallAfterCloseApp”. as below.

![](https://s3.amazonaws.com/katalon-forum/editor/ec/1fx1h5cmopun.png "Image: https://s3.amazonaws.com/katalon-forum/editor/ec/1fx1h5cmopun.png")

Thanks,  
Mosaj

[Capture.PNG](https://s3.amazonaws.com/katalon-forum/editor/ec/1fx1h5cmopun.png)

---

<div class="post-metadata">

**Author:** ![Robin](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@Robin](https://forum.katalon.com/u/Robin)\
**Post date:** [February 7, 2018, 1:21pm UTC](https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927/5 "2018-02-07T13:21:43Z")

</div>

Katalon: 5.3.0.1  
Java: 1.8.0\_102  
Appium: 1.7.2

But it’s still not working with those settings…

---

<div class="post-metadata">

**Author:** ![Robin](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@Robin](https://forum.katalon.com/u/Robin)\
**Post date:** [February 28, 2018, 9:17am UTC](https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927/6 "2018-02-28T09:17:45Z")

</div>

I managed to work around this using the test listeners

```auto
class TestListener {
	def isTestSuite = false
	@BeforeTestCase
	def beforeTestCase(TestCaseContext testCaseContext) {
    	   if(!isTestSuite){
		Mobile.startApplication(GlobalVariable.APK_PATH, false)
	   }
	}
	@AfterTestCase
	def afterTestCase(TestCaseContext testCaseContext) {
	   if(!isTestSuite){
           	Mobile.closeApplication()
	   }
	}
	@BeforeTestSuite
	def beforeTestSuite(TestSuiteContext testSuiteContext) {
           isTestSuite = true
	   Mobile.startApplication(GlobalVariable.APK_PATH, false)
	}
	@AfterTestSuite
	def afterTestSuite(TestSuiteContext testSuiteContext) {
	   isTestSuite = false
           Mobile.closeApplication()
	}
}

```

---

<div class="post-metadata">

**Author:** ![satya2](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@satya2](https://forum.katalon.com/u/satya2)\
**Post date:** [October 12, 2018, 2:12pm UTC](https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927/7 "2018-10-12T14:12:18Z")

</div>

> [Robin](https://forum.katalon.com/profile/74/Robin) said:
> 
> I managed to work around this using the test listeners
> 
> ```auto
> class TestListener {
> 
> ```

```
def isTestSuite = false
@BeforeTestCase
def beforeTestCase(TestCaseContext testCaseContext) {
	   if(!isTestSuite){
	Mobile.startApplication(GlobalVariable.APK_PATH, false)
   }
}
@AfterTestCase
def afterTestCase(TestCaseContext testCaseContext) {
   if(!isTestSuite){
       	Mobile.closeApplication()
   }
}
@BeforeTestSuite
def beforeTestSuite(TestSuiteContext testSuiteContext) {
       isTestSuite = true
   Mobile.startApplication(GlobalVariable.APK_PATH, false)
}
@AfterTestSuite
def afterTestSuite(TestSuiteContext testSuiteContext) {
   isTestSuite = false
       Mobile.closeApplication()
}

```

}

> ```auto
> 
>   
> 
> ```

Thanks It worked to me

---

<div class="post-metadata">

**Author:** ![U.G.Chinthaka\_Devind](https://avatars.discourse-cdn.com/v4/letter/u/a183cd/32.png) [@U.G.Chinthaka\_Devind](https://forum.katalon.com/u/U.G.Chinthaka_Devind)\
**Post date:** [November 1, 2018, 3:50am UTC](https://forum.katalon.com/t/android-app-restarts-after-each-test-case/8927/8 "2018-11-01T03:50:44Z")

</div>

@[satya](http://forum.katalon.com/profile/11263/satya) where to add this listener?
