By using groovy scripts local property value is not updated in SOAP UI - soap

I have written below groovy script to update the local test case property values in Properties tab:
String testString = "TestString"
testRunner.testCase.setPropertyValue( "Pro_Response", testString )
def getLocalPropValue = testRunner.testCase.getPropertyValue("Pro_Response")
log.info(getLocalPropValue)
So after running this groovy script my expected out put is Pro_Response property should be updated with testString value. But this is not happening.
Note: There is no issues wit the groovy log.info(getLocalPropValue) is giving me the testString value in script output.
Can anyone plse suggest

I have found below solution for this issue:
Since I was looking to modify the property in Properties test step:
I need to modify below existing line of code:
testRunner.testCase.setPropertyValue( "Pro_Response", testString )
Like below:
testRunner.testCase.testSteps["Properties_2"].setPropertyValue( "Pro_Response", testString )

Related

Test name as given with collect-only

I would like to access the name of the current test as a string in my tests to write some VCD log-files.
Is the name as given when I run pytest --collect-only available as a fixture or equivalent?
Example:
Running pytest --collect-only yields (shorted):
<Class TestFooBar>
<Function test_30_foobar[1-A]>
In my test I would like to access the above string test_30_foobar[1-A].
Is there a (simple) way?
I've found an answer for my own question. It's hidden in the request fixture. See the following thereof derived fixture:
#pytest.fixture
def name_test(request):
"""Make name of test available as string and escaped as filename"""
import types
i = types.SimpleNamespace()
i.name = request.node.name
i.filename = i.name.replace('[', '_').replace(']', '')
return i
The filename variable is a clumsily escaped string that should be a valid filename. However, only tested on POSIX so far.

Adding user defined keywords or Test Attribute

I would like to add custom attributes (or Keywords) to a test which I can access during pytest_runtest_logreport.
What I have been doing currently is to set a marker like this
#pytest.mark.TESTID(98157) for tests and then use this in pytest_runtest_logreport as report.keywords['TESTID'] which returns a tuple of length 1 having value 98157. So far so good.
But when I tried to add another marker with defect ID like this #pytest.mark.JIRA("MyJIRA-124") this report.keywords['JIRA'] this gives me integer 1.
So my question is can we not create parameterized marker with string parameters
AND
If that is the could be the probable workaround for me.
Unfortunately "report" will not have this vaules in default implmentation as it's only a dict with 1 as values for each key (source code)
I think that the easiest workaround would be to change how the "report" is constructed using pytest_runtest_makereport hook. It could be as simple as this:
from _pytest.runner import pytest_runtest_makereport as _makereport
def pytest_runtest_makereport(item, call):
report = _makereport(item, call)
report.keywords = dict(item.keywords)
return report
Then in pytest_runtest_logreport, under report.keyword['JIRA'] you will find MarkInfo object

Get "name" for object, corresponding to package name and object name

Given the object:
package com.foo.bar
object Sample {
val LOG = org.slf4j.LoggerFactory.getLogger(???)
....
}
what statement/function/whatever I put into getLogger statement in order to get "com.foo.bar.Sample" ?
Basically, it's just a matter of code style, for the moment I configured IntelliJ to generate LOG statements with strings, evaluated from template like "packagename.classname". But may be there's some better way?
Thanks.
In this case you could use getClass().getName().

Unable to use Variable in XPath in Eclipse - Selenium

I need to pass values from excel sheet ( stored in variable api ) to XPATH in eclipse (java - Selenium).
I tried several options but none works. Please guide.
Here is my line of code.
String appcode = //input[contains(#id,'app') and contains(#type,'text') and ancestor::div[contains(#id, '+api+')]]
When i hardcode the value of api as below it works.
String appcode="//input[contains(#id,'app') and contains(#type,'text') and ancestor::div[contains(#id, 'setmember')]]";
Isnt it this easy?
Appreciate your help
pk
you probably did not end the String constructor properly. Try this:
String appcode = "//input[contains(#id,'app') and contains(#type,'text') and ancestor::div[contains(#id, '" +api+" ')]]";
My assumption is, that api variable is type String
you can use \" so you would have something like
String appcode ="//input[contains(#id,\" "+[VARIABLE]+ " \")[..] ";

FakeItEasy & "params" arguments

I have a method with the following signature.
Foo GetFooById( int id, params string[] children )
This method is defined on an interface named IDal.
In my unit test I write the following:
IDal dal = A.Fake<IDal>();
Foo fooToReturn = new Foo();
fooToReturn.Id = 7;
A.CallTo(()=>dal.GetFooById(7, "SomeChild")).Returns(fooToReturn);
When the test runs, the signature isn't being matched on the second argument. I tried changing it to:
A.CallTo(()=>dal.GetFooById(7, new string[]{"SomeChild"})).Returns(fooToReturn);
But that was also unsuccessful. The only way I can get this to work is to use:
A.CallTo(()=>dal.GetFooById(7, A<string[]>.Ignored )).Returns(fooToReturn);
I'd prefer to be able to specify the value of the second argument so the unit test will break if someone changes it.
Update: I'm not sure when, but the issue has long since been resolved. FakeItEasy 2.0.0 supports the desired behaviour out of the box.
It might be possible to special case param-arrays in the parsing of the call-specification. Please submit an issue at: https://github.com/patrik-hagne/FakeItEasy/issues?sort=created&direction=desc&state=open
Until then, the best workaround is this:
A.CallTo(() => dal.GetFooById(7, A<string[]>.That.IsSameSequenceAs("SomeChild"))).Returns(fooToReturn);