Parameter 'google' is required by @Configuration on method setUp but has not been marked @Optional or defined

后端 未结 4 1577
小鲜肉
小鲜肉 2021-01-06 14:36

There are couple of thread regarding same error but they are not active ,I think last they were active was around 1 yr back so I am opening the new thread .

相关标签:
4条回答
  • 2021-01-06 15:12

    Though it seems to be a very old post, I am sharing the solution which worked for me.

    Basically it requires two settings for TestNG Run 'Class' and 'Suite'

    To set the TestNG Run 'Class'
    Step1: Goto Project => Run As => Run Configurations => 'Test' tab
    Step2: Check option 'Class'. It should be the set with desired '.java' file.
    e.g. 'functionalTestCases.java' is on package 'testCases' then 'Class' will be set as 'testCases.functionalTestCases.java'
    Step3: Verify the 'Name' field. e.g It can be 'functionalTC'
    Step4: Save the changes using 'Apply' button

    To set the TestNG Run 'Suite' Step1: Goto Project => Run As => Run Configurations => 'Test' tab
    Step2: Check option 'Suite'. It should be the set with desired 'testng.xml' file path.
    Step3: Verify the 'Name' field.
    e.g It can be 'projectname_testng.xml'
    Step4: Save the changes using 'Apply' button

    After these setting are saved properly, then Run the project with 'projectname_testng.xml'

    Also, I am using TestNG annotation as '@BeforeClass' for the method (which refers and checks the 'parameter' passed from 'testng.xml') in 'testCases.functionalTestCases.java'

    0 讨论(0)
  • 2021-01-06 15:17

    It seems that TestNG created the testng.xml programatically because it can't find your testng.xml or you ran your project as a TestNG Test instead of your testng.xml file.

    0 讨论(0)
  • 2021-01-06 15:27

    If you want to run only your suite xml file, you need to select your suite file and select Run As-> TestNG Suite.

    However, if you want to select a particular test and use the non test part of your suite file i.e. the suite/listeners/parameters section, then you can set this file as a template xml by going to Project Properties->TestNG -> Template XML File (give absolute path of your testng xml here)

    0 讨论(0)
  • 2021-01-06 15:27

    This is probably due to running as @Test. You need to run it at Suite Level

    0 讨论(0)
提交回复
热议问题