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

Absent Code attribute in method that is not native or abstract in class file android/content/Context #91

Open
AlexeyKolosov opened this issue Feb 17, 2023 · 0 comments

Comments

@AlexeyKolosov
Copy link

AlexeyKolosov commented Feb 17, 2023

Hi, I'm using your hidden API, but having an issue with tests:
For unknown reason I can't mock android classes, such as Content in my Android project unit tests. So it gives error:

"Absent Code attribute in method that is not native or abstract in class file android/content/Context"
The example of a functionality and a test:

class SomeClassWithAndroidClass(
    private val context: Context // this even is not used, but fails
) {
    val myField = 42
}

class SomeClassWithAndroidClassTest {
    @Test // import org.junit.jupiter.api.Test
    fun `Verify field`() {
        val someClassWithAndroidClass = SomeClassWithAndroidClass(mockk())
        assert(someClassWithAndroidClass.myField == 3)
    }
}

I use jupiter version 5.8.1, junit platform version 1.8.1, mockk version 1.12.0, kotlin version 1.6.21 in build.gradle I have:

android {
    testOptions {
        unitTests.returnDefaultValues = true
        unitTests.all {
            useJUnitPlatform()
        }
    }
   ...

     compileSdkVersion 30
     defaultConfig {
         minSdkVersion 28
         targetSdkVersion 30
     }
   ...
}

Maybe you have an idea, what can resolve this?

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

1 participant