Parameter definition in testng.xml not working


#1

I am evaluating Webtestit and try to define parameters for test methods according to TestNG in resources\testng.xml file. Annotation of test method is correct and the parameters are correctly set in XML file. It is not working at all :confused: I just get the @Optional values passed to the test method. So it seems that the values from testng.xml are not read.
Could it be that this is not possible or is there another way in Webtestit?


#2

Hello @maxmustermann!
is " @Optional values passed to the test method." the error you are getting in the log when trying to set parameters? Can you maybe send us a screenshot?
Have you tried setting your parameters using the @DataProvider?
Also, you can download the Java data-driven sample project and explore a bit more. The project is available from the welcome screen under the samples category or here
Best,
Sasa


#3

Hi @smatijas,
thanks for the quick reply. What I tried to achive was using parameters as described here:
https://testng.org/doc/documentation-main.html#parameters-testng-xml

Thats my testng.xml files content:
image

Here is the test method that should make use of the parameters:

That fails with error messsage “Parameter ‘testUrl’ is required by @Test on method SearchTestCase but has not been marked @Optional or defined.”
The method executes when I add optional decorators:

But in that case the method is always called with the optional parameter values. So the parameters defined in testng.xml have no effect.

I got things working with a dataprovider solution described here:
https://testng.org/doc/documentation-main.html#parameters-dataproviders

The original problem ist still not solved. Why is that testng.xml parameter solution not working?


#4

Hi again @maxmustermann
About running tests using parameters from the testng.xml file:
Seems like your parameters setup is correct, please try to run the tests using “Run all test files” button from the execution tab.
This way you are running the test from the XML file where your parameters are mapped, and using the “Run current test file” you are running an individual class and that leads to this *“Parameter ‘testUrl’ is required by @Test on method SearchTestCase but has not been marked @Optional or defined"*error.


#5

Thanks again @smatijas
Your solution works fine. But you have to use the “HTTP” (not HTTPS) url for DTD. Otherwise an exception occurs. When using the “correct” HTTPS address, Webtestit complains about problems in testng.xml…

This help request is solved for me now. Thanks a lot.

One other small point: It would be nice if there could be implemented an XML syntax check to XML files. A small typo or missing slash leads to exceptions and hard to find issues. The user has to figure out what went wrong by searching in console and/or log output.


#6

About correct HTTPS address, we found some issues that need to be addressed, and this issue will be fixed with the upcoming release.
We do have an integrated XML auto-complete feature, so if you try to add classes, for example, you will get the auto-complete feature triggered.

And about the Syntax checking, if you observe the pom.xml file we have the syntax scheme checker implemented there so if you misspell dependancy you will get the error warning :

But currently we don’t have this feature implemented in the testng.xml that you are referring to, but we will try to find a way to do so :slight_smile:
Best,
Sasa


#7

It all boils down to the pom.xml file making use of XSD validations vs the testng.xml leveraging DTD files.

So we dug in a bit here and it seems that our version of the language server for XML does not support DTD files to drive its autocompletion features. There is a more recent version, claiming to do so, so we’ll check that out and see how to get it updated. If all goes well we should then be able to have the same features for both validation types.