Does jBehave work with Robolectric?

391 Views Asked by At

I'd like to use Behavior Driven Development (BDD) to develop an Android app. I'm thinking of using jBehave with Robolectric. Someone wrote about using jBehave with Robotium but does anyone know if Robolectric can be used instead of Robotium with jBehave?

Any known issues?

1

There are 1 best solutions below

2
On

Robotium is a tool for unit/acceptance testing on emulator or real device, Robolectric is library to unit test android code on desktop jvm. I think it would be possible to pair jBehave with Robolectric but again as for me it would be something that doesn't fit well.

As example simple behaviour test on android:

Activity A with list, user press item at position 2, user see Activity B details 
for for the second object in the list. 

Test on Robotium will:

  • press on activity A list item
  • check that activity B shown with UI that represents details

Tests with Robolectric are smaller:

  • you could check that pressing item on A will fire Intent for launching new activity with specified details
  • another test would check that B will show details

So you could try with jBehave map "see item details" to Robolectric “Intent fired” but this check is misleading because there so many things could happen from firing Intent to showing Activity with details. You could in Robolectric also try to fire activity and check details but this level of mocking is too much for BDD which suppose to have as less mocking as possible.