Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUnit 5 support #224

Open
matejdro opened this issue Mar 4, 2019 · 36 comments
Open

JUnit 5 support #224

matejdro opened this issue Mar 4, 2019 · 36 comments

Comments

@matejdro
Copy link

matejdro commented Mar 4, 2019

JUnit4 is the old JUnit system that was last updated way back in 2014. JUnit5 brings many new improvements, but at the moment it is tough to use it on Android.

There is 3rd party gradle plugin that supports JUnit5: https://github.com/mannodermaus/android-junit5 and while it works fine, it especially lacks in UI rules like in ActivityRule or ServiceRule (All official rules are for JUnit4, so they have to be rewritten if one wants to use JUnit5 for instrumentation tests).

(Copied from https://issuetracker.google.com/issues/127100532)

@brettchabot
Copy link
Collaborator

Thanks for the report.

We have JUnit5 support on our roadmap, but to be honest its not a super high priority at the moment in comparison to other features.

However, we have been thinking about JUnit5 and other test frameworks when planning future APIs. In general, we're trying to make new APIs test-framework agnostic by default. For example: androidx.test.core.ActivityScenario exists as a 'core' API without any JUnit dependencies. All the meaty logic for testing Activities is contained within this API, which will be officially replacing ActivityTestRule in a future release.

The hope is then that in the future, it would be easier for us or contributors to create simple wrappers for test framework specific extensions. Like we've done for JUnit4 in androidx.test.ext.junit.rule.ActivityScenarioRule.

I haven't used JUnit5 much myself but from brief reading it looks like 'extensions' are the equivalent to Junit4 Rules? So for example, someone could hopefully easily create a JUnit5 ActivityScenarioExtension that calls launch() and close() before and after each test.

@matejdro
Copy link
Author

matejdro commented Mar 5, 2019

I haven't used JUnit5 much myself but from brief reading it looks like 'extensions' are the equivalent to Junit4 Rules? So for example, someone could hopefully easily create a JUnit5 ActivityScenarioExtension that calls launch() and close() before and after each test.

Yes, exactly.

@TWiStErRob
Copy link
Contributor

was last updated way back in 2014

Mind you that JUnit 4.13 is almost released, but I agree Jupiter is way more awesome.

someone could hopefully easily create

it would be nice to have first party support, if it's so easy I don't see why not

@mpeng3
Copy link

mpeng3 commented Apr 18, 2020

Any update on a timeline for official JUnit 5 support? This really seems like something that should be supported natively without the need for a 3rd-party plugin.

@olegivo
Copy link

olegivo commented Oct 30, 2020

Any updates? Plans?

@quentin23soleil
Copy link

👋 Welcome to 2021. Could it be possible to be updated on this?

@issamux
Copy link

issamux commented Jan 15, 2021

Any native/official JUnit 5 support for Android (no 3rd part library) ????

@Luiz-Monad
Copy link

Luiz-Monad commented Apr 2, 2021

You don't seem to have the resources to that massive scope of supporting all possible testing frameworks.
Why don't you just add support for JUnit5 and make it de-facto the testing, and ignore the others, no use uses them anyway, or they can pigback on the JUnit5 executing engine. Every developer end up having their own hacked copy of a bridge to allow JUnit5 tests to run on top of the JUnit4.
JUnitEngine5 was created precisely to solve your problems, creating another abstraction on top of it seems excessive, and that's why for 4 years, and nothing.

Anyway, I'm migrating to KoTest, so it doesn't matter anymore, as mannordemaus binding is enough to make the basics of JUnit5 run.

@testifyqa
Copy link

Would love native JUnit5 support, please make it happen

@Apple-Flavor
Copy link

welcome to 2022

@serandel
Copy link

serandel commented May 2, 2022

Come on, Google, you only had THREE years to implement this.

@mahozad
Copy link

mahozad commented May 25, 2022

Here is a related Stack Overflow post: JUnit 5 for Android testing

@serandel
Copy link

Thanks, I got it working. But it would be cool to not need an additional plug-in for this...

@Moes81
Copy link

Moes81 commented Aug 26, 2022

I hear the following sentence almost every year on Google I/O: "We listen to our developers!". Well, I would really like Google to listen to us on this one.

@TWiStErRob
Copy link
Contributor

TWiStErRob commented Aug 26, 2022

(@brettchabot, just in case, please look at this query when prioritizing based on community feedback.)

@OussamaHaff
Copy link

I hope that testing on Android will get one day the same love as Compose and all other opinionated architectural guides...

@JoseAlcerreca
Copy link
Collaborator

JUnit5 support has been in the roadmap since its release, but our developer surveys consistently rank this below other features to invest in, such as testing support in Compose, Gradle Managed Devices or Automated Test Devices.

We appreciate the feedback and we're aware some developers feel very strongly about this (in favor and against) but please remember to keep the discussion respectful and helpful.

@JoseAlcerreca
Copy link
Collaborator

(@brettchabot, just in case, please look at this query when prioritizing based on community feedback.)

Thanks, the team is aware and it's why it's in the roadmap.

@TWiStErRob
Copy link
Contributor

@JoseAlcerreca are those "other" features also the same team as the one that works on Espresso/JUnit runner? I would have thought that Compose testing is Compose UI team's responsibility, GMD is part of AGP, and ATD is done by a team that deals with Android SDK and emulators.

@dennisguse
Copy link

@JoseAlcerreca What can we do to make this happen?
Do you need engineering support?

@JoseAlcerreca
Copy link
Collaborator

are those "other" features also the same team as the one that works on Espresso/JUnit runner?

Yes, the testing team is involved one way or another in all those projects.

it would be nice to have first party support, if it's so easy I don't see why not

To clarify this, Brett was referring to the creation of an ActivityScenarioExtension, not talking about a full migration to JUnit5. This would be a non-trivial undertaking, including years of releasing and maintaining junit4 and junit5 artifacts, starting with the runner and dealing with API breakages.

I haven't used the 3p gradle plugin. It looks like it only works on API 26 and newer. Are there any other limitations?

@android android deleted a comment from tfonteyn Sep 30, 2022
@tfonteyn

This comment was marked as abuse.

@jbduncan

This comment was marked as outdated.

@FibreFoX
Copy link

FibreFoX commented Nov 6, 2022

So this issue is open for over 3 years now .... is there any way to see what priority JUnit 5 support actually has? Right now I am not being able to even guess when this might be available.

@tagirf
Copy link

tagirf commented Jan 15, 2023

Welcome to 2023. Any plans on adding this?

@vinipazzini
Copy link

Is it time?

@azamattkhagalegov
Copy link

Please add support JUnit5

@PikalovPavel
Copy link

April 2023, still waiting.

@NebilHassen
Copy link

Does anybody know if jetpack Compose has an offical statement about current situation with JUnit5 (or anyhwere that states that they currently dont support JUnit5)

@nasif02
Copy link

nasif02 commented Apr 28, 2023

Its mid 2023. any update?

@JoseAlcerreca
Copy link
Collaborator

Does anybody know if jetpack Compose has an offical statement about current situation with JUnit5 (or anyhwere that states that they currently dont support JUnit5)

The ComposeTestRule is a JUnit4 rule. There's no support for JUnit5.

@CarmineLaface
Copy link

Does anybody know if jetpack Compose has an offical statement about current situation with JUnit5 (or anyhwere that states that they currently dont support JUnit5)

The ComposeTestRule is a JUnit4 rule. There's no support for JUnit5.

But I guess you test compose only in jvm, there you can use the test framework you prefer.

@serandel
Copy link

serandel commented Jun 7, 2023

I've had success using https://github.com/mannodermaus/android-junit5.

juleskers pushed a commit to juleskers/PianOli that referenced this issue Sep 8, 2023
Needs some additional plugins, because Google isn't moving on JUnit 5 support
see
- Google tracking issue:
  android/android-test#224
- Android <-> JUnit 5 plugin
  https://github.com/mannodermaus/android-junit5
- StackOverflow answer about the plugin
  https://stackoverflow.com/questions/46161113/junit-5-for-android-testing
juleskers pushed a commit to juleskers/PianOli that referenced this issue Sep 10, 2023
Our very first unit tests!

Needs some additional plugins, because Google isn't moving on JUnit 5 support.
see
- Google tracking issue:
  android/android-test#224
- Android <-> JUnit 5 plugin
  https://github.com/mannodermaus/android-junit5
- StackOverflow answer about the plugin
  https://stackoverflow.com/questions/46161113/junit-5-for-android-testing
juleskers pushed a commit to nicolasbrailo/PianOli that referenced this issue Sep 13, 2023
Our very first unit tests!

Needs some additional plugins, because Google isn't moving on JUnit 5 support.
see
- Google tracking issue:
  android/android-test#224
- Android <-> JUnit 5 plugin
  https://github.com/mannodermaus/android-junit5
- StackOverflow answer about the plugin
  https://stackoverflow.com/questions/46161113/junit-5-for-android-testing
@GyulaJuhasz
Copy link

Welcome to 2024.

@erfansn
Copy link

erfansn commented Mar 26, 2024

Hello to 1403

@vincent-paing
Copy link

One of the biggest advantage for us having Junit5 support is that we have a BFF written in Kotlin+Spring Boot. And it uses Junit 5. It's been a huge pain for us to do context switching between 4 and 5. We have a community plugin yes, but still it's missing feature like hilt injection, robolectric etc. Would be nice for Google to work on these extensions for us.

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

No branches or pull requests