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

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

Open
kvtm-monika opened this issue Apr 25, 2017 · 3 comments

Comments

@kvtm-monika
Copy link

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");

@thatdudedaniel
Copy link

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

@padmakarsrinivas
Copy link

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.

@tdoerner
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants