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

Fix for Powermock integration #2390

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
7 participants
@karlicoss
Contributor

karlicoss commented Mar 27, 2016

Follow-up for #2213. Should fix #2208 and probably, #2153.

I implemented a simple integration test to make sure Powermock isn't broken later. Although, I'm not very familiar with Maven, so there might be a better way of specifying the dependencies.

@@ -151,7 +151,7 @@ public void visible() {
assertThat(fragment.isVisible()).isTrue();
}
private static class LoginFragment extends Fragment {
public static class LoginFragment extends Fragment {

This comment has been minimized.

@karlicoss

karlicoss Mar 27, 2016

Contributor

Ok, I have no idea how it even worked before, Mockito can't mock private classes

@karlicoss

karlicoss Mar 27, 2016

Contributor

Ok, I have no idea how it even worked before, Mockito can't mock private classes

@Override
public boolean enableClassCache() {
return false;

This comment has been minimized.

@karlicoss

karlicoss Mar 27, 2016

Contributor

i-have-no-idea-what-im-doing-dog

I literally have no idea why, but apparently I need that to prevent exceptions like this:

org.mockito.exceptions.base.MockitoException: 
ClassCastException occurred while creating the mockito proxy :
  class to mock : 'android.text.TextWatcher', loaded by classloader : 'org.robolectric.internal.bytecode.InstrumentingClassLoader@26874f2c'
  created class : 'android.text.TextWatcher$$EnhancerByMockitoWithCGLIB$$1861d5df', loaded by classloader : 'org.mockito.internal.creation.util.SearchingClassLoader@5862ab28'
  proxy instance class : 'android.text.TextWatcher$$EnhancerByMockitoWithCGLIB$$1861d5df', loaded by classloader : 'org.mockito.internal.creation.util.SearchingClassLoader@6bce4140'
  instance creation by : ObjenesisInstantiator

You might experience classloading issues, disabling the Objenesis cache *might* help (see MockitoConfiguration)

    at org.robolectric.shadows.ShadowTextViewTest.whenSettingTextToNull_WatchersSeeEmptyString(ShadowTextViewTest.java:417)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:553)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:258)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:154)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassCastException: Cannot cast android.text.TextWatcher$$EnhancerByMockitoWithCGLIB$$1861d5df to android.text.TextWatcher
    at java.lang.Class.cast(Class.java:3369)
    at org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:59)
    at org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:49)
    at org.powermock.api.mockito.repackaged.CglibMockMaker.createMock(CglibMockMaker.java:24)
    at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:46)
    at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:33)
    at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59)
    at org.mockito.Mockito.mock(Mockito.java:1285)
    at org.mockito.Mockito.mock(Mockito.java:1163)
    ... 38 more
@karlicoss

karlicoss Mar 27, 2016

Contributor

i-have-no-idea-what-im-doing-dog

I literally have no idea why, but apparently I need that to prevent exceptions like this:

org.mockito.exceptions.base.MockitoException: 
ClassCastException occurred while creating the mockito proxy :
  class to mock : 'android.text.TextWatcher', loaded by classloader : 'org.robolectric.internal.bytecode.InstrumentingClassLoader@26874f2c'
  created class : 'android.text.TextWatcher$$EnhancerByMockitoWithCGLIB$$1861d5df', loaded by classloader : 'org.mockito.internal.creation.util.SearchingClassLoader@5862ab28'
  proxy instance class : 'android.text.TextWatcher$$EnhancerByMockitoWithCGLIB$$1861d5df', loaded by classloader : 'org.mockito.internal.creation.util.SearchingClassLoader@6bce4140'
  instance creation by : ObjenesisInstantiator

You might experience classloading issues, disabling the Objenesis cache *might* help (see MockitoConfiguration)

    at org.robolectric.shadows.ShadowTextViewTest.whenSettingTextToNull_WatchersSeeEmptyString(ShadowTextViewTest.java:417)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:553)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:258)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:154)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassCastException: Cannot cast android.text.TextWatcher$$EnhancerByMockitoWithCGLIB$$1861d5df to android.text.TextWatcher
    at java.lang.Class.cast(Class.java:3369)
    at org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:59)
    at org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:49)
    at org.powermock.api.mockito.repackaged.CglibMockMaker.createMock(CglibMockMaker.java:24)
    at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:46)
    at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:33)
    at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59)
    at org.mockito.Mockito.mock(Mockito.java:1285)
    at org.mockito.Mockito.mock(Mockito.java:1163)
    ... 38 more

This comment has been minimized.

@hzsweers

hzsweers Mar 27, 2016

Will all consumers have to do this?

@hzsweers

hzsweers Mar 27, 2016

Will all consumers have to do this?

This comment has been minimized.

@karlicoss

karlicoss Mar 27, 2016

Contributor

Hm, nice catch. I'll check on my work tomorrow.

@karlicoss

karlicoss Mar 27, 2016

Contributor

Hm, nice catch. I'll check on my work tomorrow.

This comment has been minimized.

@karlicoss

karlicoss Mar 28, 2016

Contributor

Yeah, I guess this needs to be resolved somehow differently...

@karlicoss

karlicoss Mar 28, 2016

Contributor

Yeah, I guess this needs to be resolved somehow differently...

This comment has been minimized.

@karlicoss

karlicoss Mar 28, 2016

Contributor

Actually, the problem only arises if one uses MultiApiRobolectricTestRunner. I wonder how this cache works.

@karlicoss

karlicoss Mar 28, 2016

Contributor

Actually, the problem only arises if one uses MultiApiRobolectricTestRunner. I wonder how this cache works.

This comment has been minimized.

@kageiit

kageiit Jun 25, 2016

Contributor

instead of returning false. can we do something like

return !isMultiApiRobolectricTestRunner

@kageiit

kageiit Jun 25, 2016

Contributor

instead of returning false. can we do something like

return !isMultiApiRobolectricTestRunner

@@ -148,7 +148,7 @@ public void visible() {
assertThat(fragment.isVisible()).isTrue();
}
private static class LoginFragment extends Fragment {
public static class LoginFragment extends Fragment {

This comment has been minimized.

@karlicoss

karlicoss Mar 27, 2016

Contributor

Same here, should be public in order to be mocked.

@karlicoss

karlicoss Mar 27, 2016

Contributor

Same here, should be public in order to be mocked.

@@ -46,6 +82,12 @@
</dependency>
<dependency>
<groupId>xmlpull</groupId>

This comment has been minimized.

@hzsweers

hzsweers Mar 28, 2016

What's this for?

@hzsweers

hzsweers Mar 28, 2016

What's this for?

This comment has been minimized.

@karlicoss

karlicoss Mar 28, 2016

Contributor

So, android has its own version of xmlpull, which is loaded by the instrumenting class loader which makes it incompatible with PowerMock (it uses xmlpull for serialization). Specifying xmlpull in pom explicitly resolves that.

@karlicoss

karlicoss Mar 28, 2016

Contributor

So, android has its own version of xmlpull, which is loaded by the instrumenting class loader which makes it incompatible with PowerMock (it uses xmlpull for serialization). Specifying xmlpull in pom explicitly resolves that.

This comment has been minimized.

@hzsweers

hzsweers Mar 28, 2016

Ah interesting, might be worth adding a comment for that.

@hzsweers

hzsweers Mar 28, 2016

Ah interesting, might be worth adding a comment for that.

@jongerrish

This comment has been minimized.

Show comment
Hide comment
@jongerrish

jongerrish Mar 29, 2016

Contributor

Can you merge this?

Contributor

jongerrish commented Mar 29, 2016

Can you merge this?

@karlicoss

This comment has been minimized.

Show comment
Hide comment
@karlicoss

karlicoss Mar 29, 2016

Contributor

@jongerrish no, not yet, because of this Mockito cache thing. I'll see what else I could do about it, for now I'm temporarily closing it.

Contributor

karlicoss commented Mar 29, 2016

@jongerrish no, not yet, because of this Mockito cache thing. I'll see what else I could do about it, for now I'm temporarily closing it.

@karlicoss karlicoss closed this Mar 29, 2016

@hzsweers

This comment has been minimized.

Show comment
Hide comment
@hzsweers

hzsweers Apr 2, 2016

Any updates? I'd personally rather have this and a route to a working powermock than none at all, especially if it's only an issue in certain cases (like using the test runner you mentioned)

hzsweers commented Apr 2, 2016

Any updates? I'd personally rather have this and a route to a working powermock than none at all, especially if it's only an issue in certain cases (like using the test runner you mentioned)

@karlicoss

This comment has been minimized.

Show comment
Hide comment
@karlicoss

karlicoss Apr 2, 2016

Contributor

@hzsweers I still didn't figure out this cache thing, which will break robolectric for people who don't use powermock as well, so it can't get merged like this. I am debugging it when i have time, so I hope to figure the problem out soon.

Contributor

karlicoss commented Apr 2, 2016

@hzsweers I still didn't figure out this cache thing, which will break robolectric for people who don't use powermock as well, so it can't get merged like this. I am debugging it when i have time, so I hope to figure the problem out soon.

@mplacona

This comment has been minimized.

Show comment
Hide comment
@mplacona

mplacona Jul 10, 2016

Any possible updates on this? Or even a workaround?

mplacona commented Jul 10, 2016

Any possible updates on this? Or even a workaround?

@PhilippeBoisney

This comment has been minimized.

Show comment
Hide comment
@PhilippeBoisney

PhilippeBoisney Jul 29, 2016

Same problem here with powermock... =/
Here is my StackTrace :

> com.thoughtworks.xstream.converters.ConversionException: Cannot convert type org.apache.tools.ant.Project to type org.apache.tools.ant.Project
> ---- Debugging information ----
> class               : org.apache.tools.ant.Project$1
> required-type       : org.apache.tools.ant.Project$1
> converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
> path                : /org.powermock.modules.junit4.rule.PowerMockStatement$1/outer-class/fNext/next/this$1/outer-class/dependencyResolver/dependencyResolver/project/isLoggingMessage/outer-class
> line number         : 410
> class[1]            : org.apache.tools.ant.Project
> class[2]            : org.robolectric.internal.dependency.MavenDependencyResolver
> class[3]            : org.robolectric.internal.dependency.CachedDependencyResolver
> class[4]            : org.robolectric.RobolectricGradleTestRunner
> class[5]            : org.robolectric.RobolectricTestRunner$HelperTestRunner
> class[6]            : org.robolectric.RobolectricTestRunner$HelperTestRunner$1
> class[7]            : org.junit.internal.runners.statements.RunBefores
> class[8]            : org.powermock.modules.junit4.rule.PowerMockStatement
> class[9]            : org.powermock.modules.junit4.rule.PowerMockStatement$1
> version             : not available
> -------------------------------
> 
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:439)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
>   at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
>   at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1206)
>   at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1190)
>   at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)
>   at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1052)
>   at org.powermock.classloading.DeepCloner.clone(DeepCloner.java:54)
>   at org.powermock.classloading.ClassloaderExecutor.execute(ClassloaderExecutor.java:89)
>   at org.powermock.classloading.ClassloaderExecutor.execute(ClassloaderExecutor.java:78)
>   at org.powermock.modules.junit4.rule.PowerMockStatement.evaluate(PowerMockRule.java:49)
>   at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:265)
>   at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:191)
>   at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:56)
>   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>   at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:157)
>   at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>   at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
>   at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
>   at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
>   at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:498)
>   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

PhilippeBoisney commented Jul 29, 2016

Same problem here with powermock... =/
Here is my StackTrace :

> com.thoughtworks.xstream.converters.ConversionException: Cannot convert type org.apache.tools.ant.Project to type org.apache.tools.ant.Project
> ---- Debugging information ----
> class               : org.apache.tools.ant.Project$1
> required-type       : org.apache.tools.ant.Project$1
> converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
> path                : /org.powermock.modules.junit4.rule.PowerMockStatement$1/outer-class/fNext/next/this$1/outer-class/dependencyResolver/dependencyResolver/project/isLoggingMessage/outer-class
> line number         : 410
> class[1]            : org.apache.tools.ant.Project
> class[2]            : org.robolectric.internal.dependency.MavenDependencyResolver
> class[3]            : org.robolectric.internal.dependency.CachedDependencyResolver
> class[4]            : org.robolectric.RobolectricGradleTestRunner
> class[5]            : org.robolectric.RobolectricTestRunner$HelperTestRunner
> class[6]            : org.robolectric.RobolectricTestRunner$HelperTestRunner$1
> class[7]            : org.junit.internal.runners.statements.RunBefores
> class[8]            : org.powermock.modules.junit4.rule.PowerMockStatement
> class[9]            : org.powermock.modules.junit4.rule.PowerMockStatement$1
> version             : not available
> -------------------------------
> 
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:439)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:480)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:412)
>   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:263)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
>   at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
>   at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
>   at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1206)
>   at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1190)
>   at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)
>   at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1052)
>   at org.powermock.classloading.DeepCloner.clone(DeepCloner.java:54)
>   at org.powermock.classloading.ClassloaderExecutor.execute(ClassloaderExecutor.java:89)
>   at org.powermock.classloading.ClassloaderExecutor.execute(ClassloaderExecutor.java:78)
>   at org.powermock.modules.junit4.rule.PowerMockStatement.evaluate(PowerMockRule.java:49)
>   at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:265)
>   at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:191)
>   at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:56)
>   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>   at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:157)
>   at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>   at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
>   at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
>   at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
>   at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:498)
>   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
@darienalvarez

This comment has been minimized.

Show comment
Hide comment
@darienalvarez

darienalvarez Aug 16, 2016

I have the same problem like @PhilippeBoisney. When the patch will be available?

darienalvarez commented Aug 16, 2016

I have the same problem like @PhilippeBoisney. When the patch will be available?

@PhilippeBoisney

This comment has been minimized.

Show comment
Hide comment
@PhilippeBoisney

PhilippeBoisney Aug 17, 2016

The only workaround that I found is to downgrade Robolectric to 3.0 version... =/
testCompile "org.robolectric:robolectric:3.0"

PhilippeBoisney commented Aug 17, 2016

The only workaround that I found is to downgrade Robolectric to 3.0 version... =/
testCompile "org.robolectric:robolectric:3.0"

@jongerrish

This comment has been minimized.

Show comment
Hide comment
@jongerrish

jongerrish Aug 17, 2016

Contributor

Realistically we're not going to get to this till October, but we do
welcome contributions if you want to take a stab at fixing it yourself.

The best work around it to simply make your code testable then you don't
need to mock statics,

On 16 August 2016 at 13:13, Darien Alvarez De la Cruz <
notifications@github.com> wrote:

I have the same problem like @PhilippeBoisney
https://github.com/PhilippeBoisney. When the patch will be available?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2390 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGBaeOGUXXQiohHjg_fdYstThnLZivw_ks5qghnvgaJpZM4H5h1e
.

Contributor

jongerrish commented Aug 17, 2016

Realistically we're not going to get to this till October, but we do
welcome contributions if you want to take a stab at fixing it yourself.

The best work around it to simply make your code testable then you don't
need to mock statics,

On 16 August 2016 at 13:13, Darien Alvarez De la Cruz <
notifications@github.com> wrote:

I have the same problem like @PhilippeBoisney
https://github.com/PhilippeBoisney. When the patch will be available?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2390 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGBaeOGUXXQiohHjg_fdYstThnLZivw_ks5qghnvgaJpZM4H5h1e
.

@darienalvarez

This comment has been minimized.

Show comment
Hide comment
@darienalvarez

darienalvarez Aug 17, 2016

thank you very much, you are right but I am working with legacy code, removing all the static calls is impossible for the moment. I will try with robolectric 3.0

darienalvarez commented Aug 17, 2016

thank you very much, you are right but I am working with legacy code, removing all the static calls is impossible for the moment. I will try with robolectric 3.0

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