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

@RunWith annotation on Android fails on 1.3.1 #232

Closed
GoogleCodeExporter opened this issue Mar 24, 2015 · 7 comments
Closed

@RunWith annotation on Android fails on 1.3.1 #232

GoogleCodeExporter opened this issue Mar 24, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create a simple HelloWorld Android app.
2. Create a junit test with @RunWith(PowerMockRunner.class) annotation.
That alone causes an initializationError. don't implement any tests.
3.

What is the expected output? What do you see instead?
Expected output is a working test.
Not it fails with the following exception:

Java.lang.RuntimeException: Stub!
        at junit.runner.Version.id(Version.java:5)
        at
org.powermock.modules.junit4.PowerMockRunner.getJUnitVersion(PowerMockRunner.jav
a:32)
        at
org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:27)


What version of the product are you using? On what operating system?
Works with PowerMock 1.2.5
Broken on PowerMock 1.3.1

Os: Ubuntu 9.10
Linux a23059700-laptop 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 01:26:53
UTC 2010 i686 GNU/Linux

Android 1.6_r2 SDK jar.

Maven android plugin:
com.jayway.maven.plugins.android.generation2:maven-android-plugin
2.2.3

Please provide any additional information below.

Original issue reported on code.google.com by magnus.p...@gtempaccount.com on 8 Feb 2010 at 9:52

@GoogleCodeExporter
Copy link
Author

How about 1.3.5?

Original comment by johan.ha...@gmail.com on 8 Feb 2010 at 11:34

@GoogleCodeExporter
Copy link
Author

Will probably not work either. What JUnit version are you using? Seems really 
strange 
that version id returns "Stub!".

Original comment by johan.ha...@gmail.com on 8 Feb 2010 at 2:16

@GoogleCodeExporter
Copy link
Author

It is because it is Android. 
It is the JUnit shipped with Android 1.6_r2.
I can dig into the problem and provide a maven project with two profiles and the
android jar you will need to deploy on your local maven repository.
Just wanted to make sure the problem was logged before forgetting about it.

Original comment by magnus.p...@gtempaccount.com on 8 Feb 2010 at 2:21

@GoogleCodeExporter
Copy link
Author

Ok I wasn't aware that they stubbed out JUnit as well(?). You need a real JUnit 
implementation in order to use PowerMock, it cannot be executed with a stubbed 
version 
of JUnit. So presumely you need to have a real JUnit version that have 
precedence over 
the Android version in classpath. How ever I find it strange that version 1.2.5 
works 
though, or could it be that the version id is stubbed in the Androind jar but 
other 
than that it's still a functional JUnit? That would explain why it's still 
works in 
1.2.5 because checking the JUnit version was made in 1.3 to allow for JUnit 
rules.

Original comment by johan.ha...@gmail.com on 8 Feb 2010 at 2:30

@GoogleCodeExporter
Copy link
Author

Could be so. It is not run on the phone. Could be that I am doing something 
wrong so
when testing the junit in the Android jar is used instead of my maven 
dependency jar?

Attaching a simple project as zip (packaged with jar)

mvn test -Pbroken (default 1.3.1 powermock version)
mvn test -Pworking (1.2.5 powermock version)





Original comment by magnus.p...@gtempaccount.com on 8 Feb 2010 at 2:47

Attachments:

@GoogleCodeExporter
Copy link
Author

Yes, that was the case.
If I move the android.jar dependency after the JUnit dependency in the pom it 
works.

Original comment by magnus.p...@gtempaccount.com on 8 Feb 2010 at 2:49

@GoogleCodeExporter
Copy link
Author

Ah that's really good to know. Thanks for the description. If this comes up 
again I'll 
write a FAQ entry about it.

Original comment by johan.ha...@gmail.com on 8 Feb 2010 at 7:06

  • Changed state: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant