vitsvg
11 years agoOccasional Contributor
[Res] addAssertion method returns null for AssertionTestStep
Hi there,
I'm using soap UI Pro 4.6.1. and adding ProXPathContainsAssertion dynamically (or XPathContainsAssertion) to the AssertionTestStep by using the following code:
def testStep = context.testCase.testSteps["NameOfTheStep"];
def assertion = testStep.addAssertion("XPath Match");
assertion.name = "NameForAssertion";
It fails with the java.lang.NullPointerException: Cannot set property 'name' on null object at the last statement. Hence the method of assertion creation (testStep.addAssertion) returns null.
If I use the target test case of a different type (e.g. Http Test Request Step) then it works fine without any issues.
I had once the assertion addition worked for me for the AssertionTestStep by incident and then it started to fail again.
Can you please advise if there are any known issues with this method? Or maybe you can just check that unit-tests are not failing for this method?
Should I add a new assertion in a different way for the Assertion Step compared to HttpTestRequest one?
Full scenario to reproduce the problem is below.
1. Create a new test case
2. Add a new AssertionStep
3. Add a new Groovy Script step
4. In the Groovy Script do the following:
a) get the reference to the previously created AssertionStep (via context.testCase.getTestStepAt(0))
b) try to add an assertion of XPath Match to the assertion step
c) assert if the new assertion is not null - you can use log.info(assertion) which would show if assertion instance is NULL or has a value (in which case it will log the class name).
In my case at the point 4c I'm getting an issue that assertion is NULL and I can't change any properties of the assertion instance.
Please assist.
I'm using soap UI Pro 4.6.1. and adding ProXPathContainsAssertion dynamically (or XPathContainsAssertion) to the AssertionTestStep by using the following code:
def testStep = context.testCase.testSteps["NameOfTheStep"];
def assertion = testStep.addAssertion("XPath Match");
assertion.name = "NameForAssertion";
It fails with the java.lang.NullPointerException: Cannot set property 'name' on null object at the last statement. Hence the method of assertion creation (testStep.addAssertion) returns null.
If I use the target test case of a different type (e.g. Http Test Request Step) then it works fine without any issues.
I had once the assertion addition worked for me for the AssertionTestStep by incident and then it started to fail again.
Can you please advise if there are any known issues with this method? Or maybe you can just check that unit-tests are not failing for this method?
Should I add a new assertion in a different way for the Assertion Step compared to HttpTestRequest one?
Full scenario to reproduce the problem is below.
1. Create a new test case
2. Add a new AssertionStep
3. Add a new Groovy Script step
4. In the Groovy Script do the following:
a) get the reference to the previously created AssertionStep (via context.testCase.getTestStepAt(0))
b) try to add an assertion of XPath Match to the assertion step
c) assert if the new assertion is not null - you can use log.info(assertion) which would show if assertion instance is NULL or has a value (in which case it will log the class name).
In my case at the point 4c I'm getting an issue that assertion is NULL and I can't change any properties of the assertion instance.
Please assist.