Is there a way to set test running order in android?
I use Espresso framework and need to test a lot of activities and transitions between them. I want to write different test for those activities, but I need a specific order for running those tests.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Add the annotation @FixMethodOrder(MethodSorters.NAME_ASCENDING) on top of the class name and name the methods in ascending order.
Please see the below links. The answer is there to achieve your need.
https://stackoverflow.com/a/41198659/4675067
https://stackoverflow.com/a/34456810/4675067
Yes You can set order using the order no with the test_name, See the below example-
You can add annotation as test runner fixture as shown here:
just above class name
I need to test loginActivity test first, if it succeeds , it will login the user.And, then I should test other activities. LogoutActivity test should run at the end. So, sequence of activity test is required.
espresso set running order of tests
From Junit 4.11 comes with @FixMethodOrder annotation. Instead of using custom solutions just upgrade your junit version and annotate test class with FixMethodOrder(MethodSorters.NAME_ASCENDING). Check the release notes for the details.
Here is a sample:
As @spinster said above, you should write your tests in a way where order doesn't matter.
I believe Junit 3 will run tests in alphabetical order of the fully qualified class name, so in theory you could control the order by naming them ( package name, class name, method name ) alphabetically in the order you would like them executed, but I would not recommend that.
See: How to run test methods in specific order in JUnit4? How to pre-define the running sequences of junit test cases?