Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Conversation

@WonderCsabo
Copy link
Member

Implements #973.

This is not done, because there is an issue with ParameterizedRobolectricTestRunner as noted in #973, but i push it here so code review and ideas around the bug can be started.
Also this PR is depends on #983.

Initial implementation for upgrading to Robolectric 2.2.
SaveInstanceStateActivityParameterizedTest is failing, which is due to
a Robolectric bug described in androidannotations#973.
This commit dependes on RoboGuice 2 which is implemented in androidannotations#983.

All other tests should be OK. This involves lots of code change and
simplification thanks to Robolectric 2.2.
The ParameterizedRobolectricTestRunner has a problem: when creating the
test parameter objects, it uses the default ClassLoader, but for the
tests it uses the Robolectric ClassLoader. This results in errors since
objects cannot be used altogether which are originating from different
ClassLoaders.
This commit fixes this issue by creating a workaround class which loads
Robolectric with a fake test, aquire the Robolectric ClassLoader and
creates the test parameter objects with that.
@WonderCsabo
Copy link
Member Author

I managed to create a workaround, so now all tests run correctly. Please review this PR as soon as you can because it is difficult to update it every time if the other contributors still use Robolectric 1.

@yDelouis
Copy link
Contributor

👍 for reviewing quickly.
Imagine my pain when waiting 6 months for my PR #619 to be merged and merging all others PR merged during this period. ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you comment out @Roboguice and let this Activity extends RoboActivity ?
The purpose of @Roboguice is to prevent the user from having to let their Activity extends RoboActivity.

@yDelouis
Copy link
Contributor

I've made a review of this PR and it seems great.
I have not enough knowledge about Robolectric to review the workaround but tests are passing, and, when we modify the code, they fail when they should.
I have just one comment about @Roboguice been commented out.

@WonderCsabo
Copy link
Member Author

Thanks for the review. As you can see, i also updated RoboGuice support to version 2. I commented out the annotation because it was not working yet, etc, but i forgot to re-add it. Now i finished #983 so the tests are running in conjunction with that PR.

@WonderCsabo
Copy link
Member Author

Robolectric 2.3 just has been released. I think i'll update this PR to use the new version. @yDelouis, @DayS do you agree?

@yDelouis
Copy link
Contributor

Why not.

@WonderCsabo
Copy link
Member Author

I updated to PR to use Robolectric 2.3. The workaround had to be modified a little because the crucial fields in RobolectricTestRunner are changed from static to instance scope. Also the projects had to be updated to Android 4.1 because the Robolectric 2.3 only supports Android 4.1, 4.2 and 4.3, and only 4.1 is in Maven Central.

@WonderCsabo WonderCsabo changed the title Update to Robolectric 2.2 Update to Robolectric 2.3 May 27, 2014
Robolectric 2.3 was just released, so this commit upgrades to the
latest version. Since Robolectric only works with API level 16 and up,
the test app project and the test project now uses that.
@DayS
Copy link
Contributor

DayS commented May 31, 2014

Imagine my pain when waiting 6 months for my PR #619 to be merged and merging all others PR merged during this period. ;-)

@yDelouis > Yeah.. Sorry about that :x

@WonderCsabo > Did you try to launch a mvn clean test from the root of AA ?
It seems you forgot to update some classes in functional-test-1-5 project :

[ERROR] /Users/dvilleneuve/androidworkspace/androidannotations/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/roboguice/ActivityWithRoboGuice.java:[37,0] Could not find the RoboGuice framework in the classpath, the following class is missing: roboguice.inject.InjectorProvider
[ERROR] /Users/dvilleneuve/androidworkspace/androidannotations/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/roboguice/ActivityWithRoboGuice.java:[37,0] Could not find the RoboApplication class in the classpath, are you using RoboGuice 1.1.1 ?

@WonderCsabo
Copy link
Member Author

Of course. As i already told to @yDelouis, this PR works in conjunction with the RoboGuice 2 PR.

@DayS
Copy link
Contributor

DayS commented May 31, 2014

Oops, I forgot about that, sorry. I'm reviewing this right now

@DayS DayS merged commit 412b7bf into androidannotations:develop May 31, 2014
@DayS
Copy link
Contributor

DayS commented May 31, 2014

Great job 👍 Thanks a lot for this

@WonderCsabo WonderCsabo deleted the 973_Robolectric-2.2 branch May 31, 2014 19:28
@WonderCsabo
Copy link
Member Author

Thanks! Now i can merge the two test projects. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants