🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@seadowg
Copy link
Collaborator

@seadowg seadowg commented Jul 31, 2022

Closes #10275

As requested, update the README example based on the docs changes in robolectric/robolectric.github.io#115.

README.md Outdated

```java
@RunWith(AndroidJUnit4.class)
@RunWith(RobolectricTestRunner.class)
Copy link
Member

Choose a reason for hiding this comment

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

@seadowg What about keeping using AndroidJUnit4?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'd also recommend using AndroidJUnit4 by default as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I went with RobolectricTestRunner to keep it consistent with http://robolectric.org/. I had switched away from using AndroidJUnit4 on the website because using that runner requires also having androidx.test.ext:junit as a dependency.

Personally, I like the idea of having Robolectric docs focus on Robolectric in isolation and then have extra docs that describe using it as part of AndroidX Test (like http://robolectric.org/androidx_test/ and Android official docs).

Copy link
Member

Choose a reason for hiding this comment

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

@hoisie I agree with @seadowg thought. Maybe we can add new commits to add special examples with AndroidJUnit4.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any update on the thinking here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry for the delay in replying @utzcoz! I'm happy to wait for a reply from @hoisie to my follow-up on that if we're not happy to merge on the single approval:

I went with RobolectricTestRunner to keep it consistent with http://robolectric.org/. I had switched away from using AndroidJUnit4 on the website because using that runner requires also having androidx.test.ext:junit as a dependency.

I think we'll end up repeating these points in a new PR otherwise, and I don't think the change to try-with-resources is high priority enough to need to get through now seeing as we've already made the change to the website.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any update on this? If it's still preferred that we use AndroidJUnit4 as the runner in examples, then I'd suggest we also add androidx.test.ext:junit as a dependency in the "Starting a New Project" section. Happy to go with that if it'd make more sense to everyone!

Copy link
Member

Choose a reason for hiding this comment

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

@seadowg Sorry for delaying response. Current state looks great to me. But it needs @hoisie review suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey sorry for not getting back to this. We should keep it as AndroidJUnit4.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great! I've updated the build.gradle example to include the dependency needed for AndroidJUnit4 as well then.

@seadowg seadowg requested review from hoisie and utzcoz August 1, 2022 19:08
@utzcoz
Copy link
Member

utzcoz commented Sep 19, 2023

@hoisie @seadowg I think we can discuss this PR again. After long time, and a short recapping, I prefer to keep two samples: the sample with RobolectricTestRunner and the sample with AndroidJUnit4 and with AndroidX test dependency requirements.

@seadowg
Copy link
Collaborator Author

seadowg commented Sep 26, 2023

I prefer to keep two samples: the sample with RobolectricTestRunner and the sample with AndroidJUnit4 and with AndroidX test dependency requirements.

That would make sense to me! We could add the AndroidX dependency requirements to https://robolectric.org/androidx_test/.

@seadowg
Copy link
Collaborator Author

seadowg commented May 20, 2024

@hoisie @utzcoz any update on this? The example in README.md is still out of date with https://robolectric.org, and doesn't work without additional dependencies (androidx.test.ext:junit).

@utzcoz
Copy link
Member

utzcoz commented May 21, 2024

@seadowg Sorry for late merging. It looks great to me. And I need wait @hoisie 's confirmation.

@seadowg
Copy link
Collaborator Author

seadowg commented Jun 26, 2024

@hoisie any chance you can look at this if it's required? As far as I can tell, the example in the README still doesn't work "out of the box".

If it's controversial which runner to use here, maybe we could just remove the example and link to the doc at robolectric.org (https://robolectric.org/getting-started/) as they seem to be staying relatively up to date.

@seadowg
Copy link
Collaborator Author

seadowg commented Nov 26, 2024

Just wanted to bump this again as the mistakes being corrected here have bled into the new official Android Robolectric docs (here). I'll file a docs issue as well, but you can see that the dependency setup wouldn't work with the example and the example uses an ActivityScenario without closing it.

@seadowg seadowg force-pushed the readme-example branch 3 times, most recently from e5e0f53 to e768257 Compare June 11, 2025 10:31
@seadowg
Copy link
Collaborator Author

seadowg commented Jun 11, 2025

@hoisie @utzcoz we'll now want to update https://robolectric.org as well to be consistent right?

Copy link
Member

@MGaetan89 MGaetan89 left a comment

Choose a reason for hiding this comment

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

One final typo, and then it should be good to merge.
Also can you squash your commits into one please?

@MGaetan89
Copy link
Member

@hoisie @utzcoz we'll now want to update robolectric.org as well to be consistent right?

Indeed, I guess it will make sense to use AndroidJUnit4 on robolectric.org as well for consistency.

This replaces the use of RobolectricTestRunner and adds the
dependencies needed to access AndroidJUnit4
@seadowg seadowg requested a review from MGaetan89 June 11, 2025 11:04
Copy link
Member

@MGaetan89 MGaetan89 left a comment

Choose a reason for hiding this comment

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

Thanks for keeping this up to date and your patience!

@MGaetan89 MGaetan89 merged commit 6c14418 into robolectric:master Jun 11, 2025
7 checks passed
MGaetan89 added a commit to MGaetan89/robolectric.github.io that referenced this pull request Jun 22, 2025
This change aligns the sample on the homepage with what has been done in robolectric/robolectric#7475
MGaetan89 added a commit to MGaetan89/robolectric.github.io that referenced this pull request Jun 22, 2025
This change aligns the sample on the homepage with what has been done in robolectric/robolectric#7475
utzcoz pushed a commit to robolectric/robolectric.github.io that referenced this pull request Jun 22, 2025
This change aligns the sample on the homepage with what has been done in robolectric/robolectric#7475
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read Me Usage Sample is wrong

4 participants