Forum Discussion

dvjensen17's avatar
dvjensen17
Occasional Contributor
9 years ago
Solved

Groovy Test Step not running while integrated into Jenkins.

I developed my test suites on Windows Ready API! 1.4.1 and use SVN to place those test suites in a repository. I configured the pom.xml so that the test suite is running but there are Groovy Test Step that I rely on that are not running. I do not have any stand alone scripts yet so I don't think I need to commit a scripts folder with the suite to SVN. All groovy code is contained in test steps.

 

The Jenkins server I'm working with is Linux and did not configure it, so I don't know how that was set up, but I can find things out about it.

 

What additional information is needed to help me get these groovy script test steps working?

 

Here is s snippet from the Jenkins console that shows some of the warnings that I am looking at:

 

Executing Maven:  -B -f /opt/jenkins/workspace/qa-account-services-tests/pom.xml clean verify
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building QA Account Service Tests 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ test-suite ---[INFO] Deleting /opt/jenkins/workspace/qa-account-services-tests/target
[INFO] 
[INFO] --- ready-api-maven-plugin:1.3.1:test (default) @ test-suite ---Downloading: https://nexus.nuskin.net/nexus/content/groups/public/eviware/reports/1.0/reports-1.0.pom
[WARNING] The POM for eviware:reports:jar:1.0 is missing, no dependency information availablelog4j:WARN Continuable parsing error 29 and column 23
log4j:WARN An element with the identifier "CONSOLE" must appear in the document.
log4j:ERROR No appender named [CONSOLE] could be found.
02:36:08,113 WARN  [ReadyApiPaths] System property 'soapui.home' is not set! Using this directory instead: .
log4j:WARN No appenders could be found for logger (com.netflix.governator.lifecycle.ClasspathScanner).
log4j:WARN Please initialize the log4j system properly.
Failed to create icon: java.lang.InternalError: Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable.
02:36:15,372 WARN  [ReadyApiPaths] System property 'soapui.home' is not set! Using this directory instead: .
02:36:15,374 WARN  [SoapUI] Missing folder [/opt/jenkins/workspace/qa-account-services-tests/ext] for external libraries
02:36:15,375 INFO  [DefaultSoapUICore] Creating new settings at [/home/jenkins/soapui-settings.xml]
02:36:15,828 WARN  [SoapUIProGroovyScriptEngineFactory] Missing scripts folder [/opt/jenkins/workspace/qa-account-services-tests/scripts]
02:36:15,832 WARN  [ReadyApiPaths] System property 'soapui.home' is not set! Using this directory instead: .
02:36:16,070 WARN  [ReadyApiPaths] System property 'soapui.home' is not set! Using this directory instead: .
02:36:16,478 INFO  [PluginManager] 0 plugins loaded in 1 ms
02:36:16,478 INFO  [DefaultSoapUICore] All plugins loaded
02:36:16,864 WARN  [ReadyApiPaths] System property 'soapui.home' is not set! Using this directory instead: .
02:36:16,864 WARN  [SoapUI] Missing folder [/opt/jenkins/workspace/qa-account-services-tests/ext] for external libraries
02:36:16,865 INFO  [DefaultSoapUICore] Creating new settings at [/home/jenkins/soapui-settings.xml]
02:36:16,883 WARN  [ReadyApiPaths] System property 'soapui.home' is not set! Using this directory instead: .
02:36:16,948 INFO  [PluginManager] 0 plugins loaded in 0 ms
02:36:16,948 INFO  [DefaultSoapUICore] All plugins loaded
02:36:17,333 INFO  [WsdlProject] Loaded project from [file:/opt/jenkins/workspace/qa-account-services-tests/Account-Service-soapui-project/]
02:36:17,840 WARN  [SoapUIProGroovyScriptEngineFactory] Missing scripts folder [/opt/jenkins/workspace/qa-account-services-tests/scripts]
02:36:18,643 INFO  [SoapUIProTestCaseRunner] Running tests in project [Account-Service]
02:36:18,646 INFO  [SoapUIProTestCaseRunner] Running Project [Account-Service], runType = SEQUENTIAL
02:36:18,662 INFO  [SoapUIProTestCaseRunner] Running TestCase [/v1/account TestCase]
02:36:18,694 INFO  [SoapUIProTestCaseRunner] running step [Increment Accout Count]
02:36:19,133 INFO  [log] This is the createAccountCount = 4
02:36:19,136 INFO  [SoapUIProTestCaseRunner] running step [Save New Account Count]
02:36:19,138 INFO  [SoapUIProTestCaseRunner] running step [POST New Account]
02:36:26,448 INFO  [SoapUIProTestCaseRunner] Assertion [Valid HTTP Status Codes] has status FAILED
02:36:26,448 ERROR [SoapUIProTestCaseRunner] ASSERTION FAILED -> Response status code:400 is not in acceptable list of status codes
02:36:26,448 ERROR [SoapUIProTestCaseRunner] POST New Account failed, exporting to [/opt/jenkins/workspace/qa-account-services-tests/target/soapui-reports//AccountService_TestSuite-v1account_TestCase-POST_New_Account-0-FAILED.txt]

 What I am doing is incrementing an account count before I use it to create a new account and the suite is failing because it is using an account name that already exists.

 

There are sundry other warnings I wouldn't mind knowing how to resolve.

 

Thanks!

  • nmrao's avatar
    nmrao
    9 years ago

    I mean try with the changes as modifed in below script (earlier suggested to use context in place of testRunner, not sure though why Jenkins unable to determine context while soapUI can work fine)

     

    //Get existing value
    def count = testRunner.testCase.testSuite.project.properties['createAccountCount'].value as int
    //Set the next value and put it back to project property
    testRunner.testCase.testSuite.project.properties['createAccountCount'].value = (count+1).toString()

17 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Would you mind posting the script that is not behaving as anticipated. Also it would help if you can provide details about the sequence of steps involved in the test case.
    • dvjensen17's avatar
      dvjensen17
      Occasional Contributor

      OK, here is the groovy test step:

       

      def createAccountCount = context.expand( '${#Project#createAccountCount}' );
      log.info("The current createAccountCount = " + createAccountCount + "\nWill be incremented.");
      return ++createAccountCount;

      Once the variable createAccountCount is incremented, it is transferred back to the Project property "createAccountCount" and used to create a new account user name in a POST to a service.

      • nmrao's avatar
        nmrao
        Champion Level 3
        • You do not need to have return in groovy script
        • Instead, need to set it back, so that updated value can be used later.
        • I believe, this should never worked, not just in jenkins like you mentioned.

        Modified script for the requested.

        //Get existing value
        def count = context.testCase.testSuite.project.properties['createAccountCount'].value as int
        //Set the next value and put it back to project property
        context.testCase.testSuite.project.properties['createAccountCount'].value = (count+1).toString()