Forum Discussion

vitsvg's avatar
vitsvg
Occasional Contributor
11 years ago

Can't create assertions for AssertionTestStep

Hi there,

I'm using soap UI Pro 4.6.1. and adding ProXPathContainsAssertion (or XPathContainsAssertion) to the AssertionTestStep by using the following code:

def testStep = 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.
It tells me that the method of assertion creation (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 step?
Is there an issue in the 4.6.1. version?
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    I see you are setting name and type of assertion. But not what is the xpath to look for and expected value which needed.

    Or post the complete script.
  • vitsvg's avatar
    vitsvg
    Occasional Contributor
    Hi Rao,

    Thanks for the response however what is the point to provide you with the XPath value if I can't access the assertion instance after its creation.

    This script is sufficient to reproduce the issue (if it can be reproduced in your environment).
    If it doesn't happen for you then it means that the issue has been fixed and I need to upgrade my soap UI to a new version.
    But if this is the case then please let me know in which particular version/build it has been fixed because sometimes it was painful for me to upgrade soap UI as we use numerous integrations with other third party libraries.

    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.
    Do you still need the complete script after this explanation?

    Do you want me to post it into the PRO forum as we are paid customers and need this problem to be resolved asap?
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    Need to go thru your post in detailed.

    If you have pro license, you are previleged to post it in Pro boards for faster resolution.
  • missicbc's avatar
    missicbc
    New Contributor
    fixed because sometimes it was painful for me to upgrade soap UI as we use numerous integrations Fut 15 Coins with other third party libraries.