@Config constants parameter could not be found in Robolectric












3















I am trying to write a Robolectric test. I was following few tutorials where they seem to be using



@RunWith(RobolectricTestRunner::class)
@Config(constants = BuildConfig::class)


to setup the test, but in my case The parameter constants does not seem to resolve.



enter image description here



My Robolectric dependency looks like this:



testImplementation "org.robolectric:robolectric:4.0.2"









share|improve this question

























  • have you resolved your issue? I'm facing the same problem.

    – taurelas
    Dec 20 '18 at 13:26











  • Not yet, I haven't been looking into it lately

    – erluxman
    Dec 20 '18 at 15:29
















3















I am trying to write a Robolectric test. I was following few tutorials where they seem to be using



@RunWith(RobolectricTestRunner::class)
@Config(constants = BuildConfig::class)


to setup the test, but in my case The parameter constants does not seem to resolve.



enter image description here



My Robolectric dependency looks like this:



testImplementation "org.robolectric:robolectric:4.0.2"









share|improve this question

























  • have you resolved your issue? I'm facing the same problem.

    – taurelas
    Dec 20 '18 at 13:26











  • Not yet, I haven't been looking into it lately

    – erluxman
    Dec 20 '18 at 15:29














3












3








3








I am trying to write a Robolectric test. I was following few tutorials where they seem to be using



@RunWith(RobolectricTestRunner::class)
@Config(constants = BuildConfig::class)


to setup the test, but in my case The parameter constants does not seem to resolve.



enter image description here



My Robolectric dependency looks like this:



testImplementation "org.robolectric:robolectric:4.0.2"









share|improve this question
















I am trying to write a Robolectric test. I was following few tutorials where they seem to be using



@RunWith(RobolectricTestRunner::class)
@Config(constants = BuildConfig::class)


to setup the test, but in my case The parameter constants does not seem to resolve.



enter image description here



My Robolectric dependency looks like this:



testImplementation "org.robolectric:robolectric:4.0.2"






android android-testing robolectric android-junit






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 14 at 20:43









halfer

14.6k758114




14.6k758114










asked Nov 26 '18 at 3:13









erluxmanerluxman

5,88534270




5,88534270













  • have you resolved your issue? I'm facing the same problem.

    – taurelas
    Dec 20 '18 at 13:26











  • Not yet, I haven't been looking into it lately

    – erluxman
    Dec 20 '18 at 15:29



















  • have you resolved your issue? I'm facing the same problem.

    – taurelas
    Dec 20 '18 at 13:26











  • Not yet, I haven't been looking into it lately

    – erluxman
    Dec 20 '18 at 15:29

















have you resolved your issue? I'm facing the same problem.

– taurelas
Dec 20 '18 at 13:26





have you resolved your issue? I'm facing the same problem.

– taurelas
Dec 20 '18 at 13:26













Not yet, I haven't been looking into it lately

– erluxman
Dec 20 '18 at 15:29





Not yet, I haven't been looking into it lately

– erluxman
Dec 20 '18 at 15:29












2 Answers
2






active

oldest

votes


















2














constants parameter is now deprecated see the doc :



constants
Deprecated.
If you are using at least Android Studio 3.0 alpha 5 please migrate to the
preferred way to configure builds for Gradle with AGP3.0
http://robolectric.org/getting-started/


The proper way to set up Robolectric per the documentation is :



android {
testOptions {
unitTests {
includeAndroidResources = true
}
}
}

dependencies {
testImplementation 'org.robolectric:robolectric:4.1'
}





share|improve this answer































    0














    Robolectric is for unit test, not for androidTest, so please confirm that your test case is under src/test, NOT under src/androidTest.






    share|improve this answer
























    • Yes is inside src/test its my reference Project/app/src/test/java/com/erluxman/productive/MainActivityRoboTest.kt

      – erluxman
      Nov 26 '18 at 3:23













    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474336%2fconfig-constants-parameter-could-not-be-found-in-robolectric%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    constants parameter is now deprecated see the doc :



    constants
    Deprecated.
    If you are using at least Android Studio 3.0 alpha 5 please migrate to the
    preferred way to configure builds for Gradle with AGP3.0
    http://robolectric.org/getting-started/


    The proper way to set up Robolectric per the documentation is :



    android {
    testOptions {
    unitTests {
    includeAndroidResources = true
    }
    }
    }

    dependencies {
    testImplementation 'org.robolectric:robolectric:4.1'
    }





    share|improve this answer




























      2














      constants parameter is now deprecated see the doc :



      constants
      Deprecated.
      If you are using at least Android Studio 3.0 alpha 5 please migrate to the
      preferred way to configure builds for Gradle with AGP3.0
      http://robolectric.org/getting-started/


      The proper way to set up Robolectric per the documentation is :



      android {
      testOptions {
      unitTests {
      includeAndroidResources = true
      }
      }
      }

      dependencies {
      testImplementation 'org.robolectric:robolectric:4.1'
      }





      share|improve this answer


























        2












        2








        2







        constants parameter is now deprecated see the doc :



        constants
        Deprecated.
        If you are using at least Android Studio 3.0 alpha 5 please migrate to the
        preferred way to configure builds for Gradle with AGP3.0
        http://robolectric.org/getting-started/


        The proper way to set up Robolectric per the documentation is :



        android {
        testOptions {
        unitTests {
        includeAndroidResources = true
        }
        }
        }

        dependencies {
        testImplementation 'org.robolectric:robolectric:4.1'
        }





        share|improve this answer













        constants parameter is now deprecated see the doc :



        constants
        Deprecated.
        If you are using at least Android Studio 3.0 alpha 5 please migrate to the
        preferred way to configure builds for Gradle with AGP3.0
        http://robolectric.org/getting-started/


        The proper way to set up Robolectric per the documentation is :



        android {
        testOptions {
        unitTests {
        includeAndroidResources = true
        }
        }
        }

        dependencies {
        testImplementation 'org.robolectric:robolectric:4.1'
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 28 '18 at 15:16









        Guerneen4Guerneen4

        300614




        300614

























            0














            Robolectric is for unit test, not for androidTest, so please confirm that your test case is under src/test, NOT under src/androidTest.






            share|improve this answer
























            • Yes is inside src/test its my reference Project/app/src/test/java/com/erluxman/productive/MainActivityRoboTest.kt

              – erluxman
              Nov 26 '18 at 3:23


















            0














            Robolectric is for unit test, not for androidTest, so please confirm that your test case is under src/test, NOT under src/androidTest.






            share|improve this answer
























            • Yes is inside src/test its my reference Project/app/src/test/java/com/erluxman/productive/MainActivityRoboTest.kt

              – erluxman
              Nov 26 '18 at 3:23
















            0












            0








            0







            Robolectric is for unit test, not for androidTest, so please confirm that your test case is under src/test, NOT under src/androidTest.






            share|improve this answer













            Robolectric is for unit test, not for androidTest, so please confirm that your test case is under src/test, NOT under src/androidTest.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 26 '18 at 3:20









            shizhenshizhen

            3,69741234




            3,69741234













            • Yes is inside src/test its my reference Project/app/src/test/java/com/erluxman/productive/MainActivityRoboTest.kt

              – erluxman
              Nov 26 '18 at 3:23





















            • Yes is inside src/test its my reference Project/app/src/test/java/com/erluxman/productive/MainActivityRoboTest.kt

              – erluxman
              Nov 26 '18 at 3:23



















            Yes is inside src/test its my reference Project/app/src/test/java/com/erluxman/productive/MainActivityRoboTest.kt

            – erluxman
            Nov 26 '18 at 3:23







            Yes is inside src/test its my reference Project/app/src/test/java/com/erluxman/productive/MainActivityRoboTest.kt

            – erluxman
            Nov 26 '18 at 3:23




















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474336%2fconfig-constants-parameter-could-not-be-found-in-robolectric%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'