Forum Discussion

zwcmic's avatar
zwcmic
New Contributor
8 months ago
Solved

Is there a way to change settings to all test cases?

Hi, we have 300+ cases, is there a way to change a setting for them all in one go?

 

I'm aware that there is a global preference, but they only apply to newly created cases.

  • You can accomplish this, as I said, with a groovy script. It's very powerful, but prone to error, so you have to be careful. There's two options here, "failOnError" which is failing as soon as there's a failure with any given step, and "failTestCaseOnError" which marks a test case failed for any given error. I think you want "failOnError" here. That said, here's some code that might help.

    // assuming you have multiple projects that you want to adjust.
    def workspace = context.testCase.testSuite.project.workspace;
    
    for (p in workspace.getProjectList())
    {
         for (s in p.testSuiteList)
         {
              for (c in s.testCaseList)
              {
                   c.getSettings().setBoolean("failOnError", true)
              }
         }
    }

3 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    The only way I know of to do this somewhat easily is to write a custom groovy script and have it process all of the 300+ test cases, changing the settings for each one that you want to adjust. What settings are you looking to change??

     

     

    • zwcmic's avatar
      zwcmic
      New Contributor

      uncheck the "abort on error" option because we now have steps at the end to record the results

      • groovyguy's avatar
        groovyguy
        Champion Level 1

        You can accomplish this, as I said, with a groovy script. It's very powerful, but prone to error, so you have to be careful. There's two options here, "failOnError" which is failing as soon as there's a failure with any given step, and "failTestCaseOnError" which marks a test case failed for any given error. I think you want "failOnError" here. That said, here's some code that might help.

        // assuming you have multiple projects that you want to adjust.
        def workspace = context.testCase.testSuite.project.workspace;
        
        for (p in workspace.getProjectList())
        {
             for (s in p.testSuiteList)
             {
                  for (c in s.testCaseList)
                  {
                       c.getSettings().setBoolean("failOnError", true)
                  }
             }
        }