Forum Discussion

Akuratere's avatar
Akuratere
New Contributor
7 years ago

Test case run fails if Properties were set in test step

Dear all,

 

I'm facing one issue with Properties values.

 

There're two properties that I'm using for iterations. If I set the value manually before the run - test case goes smoothly.

I added small script at the end of test case to clear all properties and set values for those two mentioned above:

 

propTestStep.setPropertyValue("Count", "1")
propTestStep.setPropertyValue("keyValue", "1")

 

Script is working correctly, properties being cleared and Count and keyValue indeed have "1" value assigned, BUT... if I try to run test case one more time - it fails in the very beginning with java.lang.ClassCastException:

 

TestCase failed [java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean:java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean], time taken = 2447

 

Any suggestions?

 

Many thanks in advance,

Olga

16 Replies

    • Akuratere's avatar
      Akuratere
      New Contributor

      Hi Rao,


      Sure, here's the script that erases values of properties in the test case:



      stopp = propTestStep.getPropertyValue("Stop")

      if (stopp == "T"){
      def p = myTestCase.testSteps["Properties"]
      String[] properties = new String[p.getPropertyCount()]
      properties = p.getPropertyNames()

      for (int i=0; i<properties.size();i++){
      p.setPropertyValue(properties[i], "")
      }

      propTestStep.setPropertyValue("Count", "1")
      propTestStep.setPropertyValue("keyValue", "1")
      }


      • nmrao's avatar
        nmrao
        Champion Level 3
        Which line of the script causing the issue? Stack trace from error log, please?
        Seems ok, can be optimized though.