0

Hi I am using roboelectric for unit testing of my android application. I want to compare expected intent and actual intent using assertj-android. I have added required dependency of assertj-android, even though I have done Gradle sync multiple times but still unable to import org.assertj.android.api.content.IntentAssert.

What could be the issue ? Any idea ? Thanks in advance

build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.1'
    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:3.2.2'
    testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
    androidTestCompile 'com.squareup.assertj:assertj-android:1.1.1'
}

enter image description here

N Sharma
  • 33,489
  • 95
  • 256
  • 444

1 Answers1

1

AssertJ dependency in your build.gradle is for androidTest and it should be for test since you're using Robolectric?

Piotr Zawadzki
  • 1,678
  • 1
  • 18
  • 24
  • How to compare two intent using assertj-android ? – N Sharma Feb 24 '17 at 07:42
  • I think you cannot do that with IntentAssert. You can however check the actualIntent and e.g. check its component: https://github.com/square/assertj-android/blob/master/assertj-android/src/main/java/org/assertj/android/api/content/IntentAssert.java so you would have assertThat(actualIntent).hasComponent(mainActivity, SecondActivity.class); – Piotr Zawadzki Feb 24 '17 at 07:50