I am running some espresso tests. My problem is instead of opening the Main.activity, i want to open the fragment directly which is part of main activity before starting tests.
Asked
Active
Viewed 2,126 times
0
-
Try this : https://stackoverflow.com/a/38393087/1562755 – Terril Thomas Jun 15 '17 at 03:29
2 Answers
0
You can't. The purpose of fragment is to run alongside Activity. If you want, you can create an empty activity who just run your fragment and his layout, and then put that activity as your MainActivity in the manifest

pierre-charles Mangin
- 69
- 11
0
You can perform a FragmentManager
transaction in your test.
If you are using ActivityTestRule in your test it is possible to obtain started activity with getActivity()
and then swap or add the fragment the same way it is done in the production code.

Be_Negative
- 4,892
- 1
- 30
- 33