browserstack / testng-browserstack

Selenium examples for TestNG and BrowserStack Automate
https://www.browserstack.com
73 stars 150 forks source link

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

Open kvtm-monika opened 7 years ago

kvtm-monika commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

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 commented 4 years ago

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: <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

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