Git Product home page Git Product logo

spock-powermock's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

spock-powermock's Issues

The given gradle config doesn't work

Hi,
So I have a Java project, and I'm using Spock + Powermock for writing Unit Tests. I have some tests which are fully written using Spock, and some which use Spock + Powermock. I use Powermock to test static methods. My usage of powermock is as below:

@RunWith(PowerMockRunner)
@PowerMockRunnerDelegate(Sputnik)
@PrepareForTest([class1,class2])
class Test extends Specification {
       def "test 1"(){
              setup:
              mockstatic(class1)
              class1 obj = mock(class1.class)
              ...
              ...
       }
}

The gradle configuration which I used is :

// spock
  testCompile "org.spockframework:spock-core:1.2-groovy-2.5"
  //junit
  testCompile 'junit:junit:4.12'

  // mock
  testRuntime 'cglib:cglib-nodep:3.2.6'
  testRuntime 'org.objenesis:objenesis:2.6'

  //mockito
  testCompile 'org.mockito:mockito-core:2.9.0'

  // Power mock
  testCompile 'org.powermock:powermock-api-mockito2:1.7.3'
  testCompile 'org.powermock:powermock-module-junit4:1.7.3'

When I run my test-suite, the Spock + Powermock TC's pass, but those using only Spock fail, with error message as below:

Could not create type
java.lang.IllegalArgumentException: Could not create type
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:140)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:346)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:161)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:355)
	at org.spockframework.mock.runtime.ByteBuddyMockFactory.createMock(ByteBuddyMockFactory.java:41)
	at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:42)
	at org.spockframework.mock.runtime.JavaMockFactory.createInternal(JavaMockFactory.java:58)
	at org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:38)
	at org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:42)
	at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:46)
	at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:294)
	at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:284)
	at org.spockframework.lang.SpecInternals.MockImpl(SpecInternals.java:84)
	at com.samsung.iotcloud.bixbyhint.clients.location.implementations.LocationServiceImplTest.LocationServiceImpl getLocations should return proper response(LocationServiceImplTest.groovy:29)
Caused by: java.lang.NoSuchMethodError: net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup.isAvailable()Z
	at org.spockframework.mock.runtime.ByteBuddyMockFactory.determineBestClassLoadingStrategy(ByteBuddyMockFactory.java:103)
	at org.spockframework.mock.runtime.ByteBuddyMockFactory.access$300(ByteBuddyMockFactory.java:27)
	at org.spockframework.mock.runtime.ByteBuddyMockFactory$1.call(ByteBuddyMockFactory.java:54)
	at org.spockframework.mock.runtime.ByteBuddyMockFactory$1.call(ByteBuddyMockFactory.java:43)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:138)
	... 13 more

I am stuck with this problem since a week and would greatly appreciate any fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.