How to install .apk for the first test case only and then just lunch and close the app after that for the following test cases

Hi,

I am trying to install the apk on the mobile using @BeforeClass and then using @Before to lunch the app. The purpose of this is to is to install the app before the class and then just open and close the after and before every test case(Method)

The current wayI am using is example:
@BeforeClass

 DesiredCapabilities caps = new DesiredCapabilities();

    caps.setCapability("device", "Samsung Galaxy S8 Plus");
    caps.setCapability("os_version", "7.0");
    caps.setCapability("project", "My First Project");
    caps.setCapability("build", "My First Build");
    caps.setCapability("name", "Bstack-[Java] Sample Test");
    caps.setCapability("app", "<app_url>");
 AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("https://"+userName+":"+accessKey+" localhost/wd/hub"), caps);

@Before
AndroidDriver.Lunchapp

@After
AndroidDriver.CloseApp

@AfterClass
AndroidDriver.quit

Now my problem is that it is installing the app correctly before class but for some reason it resets the app when it is trying to lunch the app. what I am trying to achive is:

Test Case1
Install the app
Configure Environment
Click ok
User redirects to the login page

Test Case 2
open the App (lunch app)
Enter user name and password
clock on login


Can someone please guide me on how to do this?

Thanks in advance!

When running the app for the second time, you would need to set the capability:

noReset : true

Source: https://appium.io/docs/en/writing-running-appium/caps/