Is there a way of testing the save and restore state code of an activity programmatically ? I mean doing this :
How to test code built to save/restore Lifecycle of an A
The testing tools offered by Android now offer a means of writing UI tests that can recreate an activity to test the save and restore flow. See the Recreate the activity section within the Test your app's activities Android Developers documentation page. An example of the syntax – taken from that page – is the following:
@RunWith(AndroidJUnit4::class)
class MyTestSuite {
@Test fun testEvent() {
val scenario = launchActivity()
scenario.recreate()
}
}