Skip to content

Error : Parameter 'config' is required by @Configuration on method setUp but has not been marked as @optional or defined. #8

Open

Description

@kvtm-monika

Error in the method :
@BeforeMethod(alwaysRun=true)
@org.testng.annotations.Parameters(value={"config", "environment"})
public void setUp(String config_file, String environment) throws Exception {
JSONParser parser = new JSONParser();
JSONObject config = (JSONObject) parser.parse(new FileReader("src/test/resources/conf/" + config_file));
JSONObject envs = (JSONObject) config.get("environments");

Activity

  1. thatdudedaniel commented on Oct 9, 2017

    @thatdudedaniel

    I haven't figured out why running the test normally from the java class is not working however running the tests from the XML files (config > single.testng.xml, right click and select run) works without issue.

    Source: https://stackoverflow.com/a/32703593

  2. padmakarsrinivas commented on Jun 1, 2018

    @padmakarsrinivas

    This is happening because, when you are running the java class, it is unable to fetch the values from the XML file while compiling.

    The parameterized test can't be run directly, you should run your TestNG XML file.

  3. tdoerner commented on Nov 27, 2019

    @tdoerner

    My test script runs without any issue when NOT in debug mode. As soon as I try using debug in Intellij I get the above mentioned error.

    This is my xml file:

    <parameter name="platform" value="Windows 10"/>
    <parameter name="spreadsheet" value="src/test/resources/snapship.xlsx"/>
    <parameter name="accounts" value="src/test/resources/accounts.xlsx"/>
    <parameter name="errors" value="src/test/resources/errordata.xlsx"/>
    
    <!-- IP of the machine with the grid -->
    <parameter name="nodeIP" value="http://localhost"/>
    <!-- Browser window size -->
    <parameter name="width" value="1200"/>
    <parameter name="height" value="2000"/>
    <!-- Page to process ling. zzz is replaced to domain-->
    <parameter name="loginPage" value = "https://zzz.canadapost.ca/cpc/en/tools.page"/>
    
    <!-- Page in the domain used by test -->
    
    <parameter name="page" value="/esto/app/snapship"/>
    
    
    <test name="Dev 13  - Chrome">
        <parameter name="browser" value="chrome-remote"/>
        <parameter name="nodePort" value="5556"/>
        <parameter name="domain" value="stg12"/>
        <classes>
    
         <class name="testcases.cssp_3756.TestBizProfDisplay"/>
    

    This is the parameters I use to run the debug:
    mvn clean test-compile surefire:test -Dmaven.surefire.debug -P test-visual

    Any help would be greatly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions