square / spoon

Distributing instrumentation tests to all your Androids.
https://square.github.io/spoon/
Apache License 2.0
2.7k stars 477 forks source link

Add save files ability to SpoonRule. #485

Closed dweebo closed 6 years ago

dweebo commented 6 years ago

As discussed in #465

Basically just copied over code from old Spoon.java implementation w/ minor changes to SpoonRule, and clear files from each device at the start of testing.

Question: Should the code in SpoonRule have tests? I see we don't have Mockito or PowerMock so it would be difficult unless we move androidy stuff out to separate classes.

edenman commented 6 years ago

Yeah, we definitely don't want to use Mockito/etc. My guess is that writing tests for SpoonRule would be more effort than it's worth, given how entangled it all is with Android, but feel free to take a crack at it.

CAH-peterhewitt commented 6 years ago

Just curious to hear why you are against Mockito? We use it heavily for our android tests and frequently mock out android classes. It is not fun but it works. Would love to hear a better alternative.

JakeWharton commented 6 years ago

Mocking is a vehicle to coupling tests to implementation details. I prefer testing strategies which force good design instead of encourage coupling. For example, the use of fakes necessitate a design that allows dependencies to be swapped and discourages reliance on the order of things called (instead relying on emulated behavior and not caring how it's called).

On Thu, Oct 19, 2017, 9:46 PM CAH-peterhewitt notifications@github.com wrote:

Just curious to hear why you are against Mockito? We use it heavily for our android tests and frequently mock out android classes. It is not fun but it works. Would love to hear a better alternative.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/square/spoon/pull/485#issuecomment-338083414, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEUCBqQBZY3DUqdslmvLu4cyMPw5fks5st_tngaJpZM4P7dAK .

dweebo commented 6 years ago

Thanks Jake, I agree with it coupling to implementation, we fight that quite a bit. Android just makes it so tough to do. Appreciate the response.