Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

[FEATURE] Ui test #17

Closed
alorma opened this issue May 20, 2019 · 6 comments
Closed

[FEATURE] Ui test #17

alorma opened this issue May 20, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@alorma
Copy link

alorma commented May 20, 2019

Is your feature request related to a problem? Please describe.

Reading documentation i don't see any topic on how to use this view with UI testing (like Espresso).

Have you any tip that you can provide, so it's easy to do a test that request to scan a barcode?

Describe the solution you'd like

On test method:

activity.findViewById<KBarcodeView>(R.id.barcodeScanner).doScan(mockBarcode)
@alorma alorma added the enhancement New feature or request label May 20, 2019
@alorma alorma changed the title [FEATURE] Title [FEATURE] Ui test May 20, 2019
@alistairsykes
Copy link
Contributor

Hi @alorma ,

I'm really interested to hear how you would like to do testing. Because of the way we structure our screens (MVVM) I have been able to provide view tests for our viewfinder sample screen.

See https://github.com/brightec/KBarcode/blob/master/app/src/androidTest/java/uk/co/brightec/kbarcode/app/viewfinder/ViewfinderScreenTest.kt

Could you maybe provide some sudo code for a couple tests you would like to be able to write.

@alistairsykes alistairsykes self-assigned this May 30, 2019
@alorma
Copy link
Author

alorma commented May 31, 2019

UHm... yes, that sounds like the way i would do it :P

I will try this weekend and tell u my results

@alorma
Copy link
Author

alorma commented May 31, 2019

Maybe, the way I would do is be able to mock (or set) the barcode live data from KView instead of set it on ViewModel.

So we can test our real ViewModel class wit it's usecases, or whatevere we use...

Does it have sense to you?

@alistairsykes
Copy link
Contributor

It makes sense, but I am not sure what value it adds. As it stands I believe you are still able to test the fragment (screen) and separately you would be able to test your viewmodel. Meaning you can cover both your classes. Are you trying to test the combined unit of the view and viewmodel? In which case, would the barcodeview not be considered part of your view and therefore not want to alter or mock it?

I think it would be nice to be able to test at a higher level, by providing an input to the Android camera. But this doesn't seem possible.

I'm not sure how possible it would be to add a method to the barcodeview which was only available in tests. I know you can add a testing annotation which should get lint to indicate that you shouldn't use it. But in terms of a more strict/forced way, I'm not sure if you can.

@alorma
Copy link
Author

alorma commented May 31, 2019

Yes, I don't like it either... so i will check your solution and see if it fits what I need :D

@alistairsykes
Copy link
Contributor

Great. Do let me know. I want this library to support people's testing needs as much as possible.

@alistairsykes alistairsykes removed their assignment Jun 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants