SoapUI 5.7.0中JsonPath匹配类断言失效(5.6.1正常)问题求助
SoapUI 5.7.0升级后JsonPath类断言执行失败问题
我司安全部门要求必须使用SoapUI 5.7.0内嵌的log4j 2.17版本,因此需要将当前使用的SoapUI v5.2.1进行升级,此前v5.6.1版本中JsonPath Match、JsonPath RegEx Match断言均可正常运行。
我在SoapUI 5.7.0上测试了多个用户脚本,均可以正常运行,但部分集成测试执行失败。多日排查未找到解决方案,由于使用完全相同的参数通过testrunner.sh命令行执行仍会复现失败问题,因此可排除业务代码本身的问题,具体复现过程如下。
复现步骤
1. 执行mockservicerunner启动Mock服务
执行命令:
mockservicerunner.sh -m"REST MockService" -p 58475 test/integration/monitoring/soapui/soapui-project.xml
执行输出日志如下:
ubuntu@tab-sabrina-dev:~/MyRepo/git/TSM/hestia-software-scripts$ mockservicerunner.sh -m"REST MockService" -p 58475 test/integration/monitoring/soapui/soapui-project.xml ================================ = = SOAPUI_HOME = /home/ubuntu/SmartBear/SoapUI-5.7.0 = ================================ OpenJDK 64-Bit Server VM warning: Option --illegal-access is deprecated and will be removed in a future release. SoapUI 5.7.0 MockService Runner 17:40:40,385 INFO [DefaultSoapUICore] Creating new settings at [/home/ubuntu/soapui-settings.xml] 17:40:45,326 INFO [PluginManager] Adding plugin from [/home/ubuntu/.soapuios/plugins/ready-mqtt-plugin-dist.jar] 17:40:45,334 INFO [PluginManager] Adding plugin from [/home/ubuntu/.soapuios/plugins/readyapi-postman-1.0.1.jar] 17:40:46,571 INFO [PluginManager] Adding plugin from [/home/ubuntu/.soapuios/plugins/ready-uxm-plugin-os-1.0.3.jar] 17:40:46,991 INFO [PluginManager] 3 plugins loaded in 1661 ms 17:40:46,992 INFO [DefaultSoapUICore] All plugins loaded 17:40:50,191 INFO [WsdlProject] Loaded project from [file:/home/ubuntu/MyRepo/git/TSM/hestia-software-scripts/test/integration/monitoring/soapui/soapui-project.xml] 17:40:50,201 INFO [SoapUIMockServiceRunner] Running MockService [REST MockService] in project [Hestia Integration] 17:40:50,201 INFO [SoapUIMockServiceRunner] Press any key to terminate 17:40:50,797 INFO [JettyMockEngine] Started mockService [REST MockService] on port [58475] at path [/] 17:40:50,803 INFO [SoapUIMockServiceRunner] MockService started on port 58475 at path [/] 17:40:50,803 INFO [SoapUIMockServiceRunner] Started 1 runner Press any key to terminate... 17:43:09,496 INFO [log] Path: /pet/findByStatus 17:43:09,623 INFO [log] QueryString: status=available 17:43:09,707 INFO [SoapUIMockServiceRunner] Handled request 1; [/pet/findByStatus] with [Available] in [0ms] at [2022-06-28 17:43:09.523] 17:43:10,732 INFO [log] Path: /pet/findByStatus 17:43:10,733 INFO [log] QueryString: status=available 17:43:10,749 INFO [SoapUIMockServiceRunner] Handled request 2; [/pet/findByStatus] with [Available] in [0ms] at [2022-06-28 17:43:10.733] 17:43:10,770 INFO [log] Path: /pet/findByStatus 17:43:10,771 INFO [log] QueryString: status=available 17:43:10,790 INFO [SoapUIMockServiceRunner] Handled request 3; [/pet/findByStatus] with [Available] in [0ms] at [2022-06-28 17:43:10.770] 17:43:10,914 INFO [log] Path: /pet/findByStatus 17:43:10,917 INFO [log] QueryString: status=available 17:43:10,931 INFO [SoapUIMockServiceRunner] Handled request 4; [/pet/findByStatus] with [Available] in [0ms] at [2022-06-28 17:43:10.915] 17:43:10,950 INFO [log] Path: /pet/findByStatus 17:43:10,951 INFO [log] QueryString: status=available 17:43:10,963 INFO [SoapUIMockServiceRunner] Handled request 5; [/pet/findByStatus] with [Available] in [0ms] at [2022-06-28 17:43:10.951]
2. 执行testrunner运行测试用例
执行命令:
testrunner.sh -rAI -Duser.timezone=UTC -Dlogfilename=TestREST_-_test_simple_success_latest.log -Derrfilename=TestREST_-_test_simple_success_errors.log -Dsoapui.log.dir=test/integration/monitoring/soapui/rest/simple/success/logs -s 'Simple - REST Only - success' -h localhost:58475 -e http://localhost:58475 test/integration/monitoring/soapui/rest/simple/success/project.xml
执行输出日志如下:
================================ = = SOAPUI_HOME = /home/ubuntu/SmartBear/SoapUI-5.7.0 = ================================ <snip> 17:59:41,810 INFO [DefaultSoapUICore] All plugins loaded 17:59:43,215 INFO [WsdlProject] Loaded project from [file:/home/ubuntu/MyRepo/git/TSM/hestia-software-scripts/test/integration/monitoring/soapui/rest/simple/success/project.xml] 17:59:43,219 INFO [SoapUITestCaseRunner] Running SoapUI tests in project [Hestia Integration] 17:59:43,220 INFO [SoapUITestCaseRunner] Running TestSuite [Simple - REST Only - success], runType = SEQUENTIAL 17:59:43,226 INFO [SoapUITestCaseRunner] Running SoapUI testcase [No assertions] 17:59:43,230 INFO [SoapUITestCaseRunner] running step [Get available pets] 17:59:44,245 INFO [SoapUITestCaseRunner] Finished running SoapUI testcase [No assertions], time taken: 731ms, status: FINISHED 17:59:44,254 INFO [SoapUITestCaseRunner] Running SoapUI testcase [Status code assertion] 17:59:44,254 INFO [SoapUITestCaseRunner] running step [Get available pets] 17:59:44,285 INFO [SoapUITestCaseRunner] Assertion [Valid HTTP Status Codes] has status VALID 17:59:44,290 INFO [SoapUITestCaseRunner] Finished running SoapUI testcase [Status code assertion], time taken: 12ms, status: FINISHED 17:59:44,290 INFO [SoapUITestCaseRunner] Running SoapUI testcase [JSON path existence assertion] 17:59:44,291 INFO [SoapUITestCaseRunner] running step [Get available pets] 17:59:44,346 INFO [SoapUITestCaseRunner] Assertion [JsonPath Existence Match - Id is returned] has status VALID 17:59:44,347 INFO [SoapUITestCaseRunner] Finished running SoapUI testcase [JSON path existence assertion], time taken: 2ms, status: FINISHED 17:59:44,350 INFO [SoapUITestCaseRunner] Running SoapUI testcase [JSON path match assertion] 17:59:44,350 INFO [SoapUITestCaseRunner] running step [Get available pets] 17:59:44,372 INFO [SoapUITestCaseRunner] Assertion [JsonPath Match - First status is available] has status FAILED 17:59:44,372 ERROR [SoapUITCaseRunner] ASSERTION FAILED -> Comparison failed for path [$..status[0]], expecting [available], actual was [[]] 17:59:44,372 ERROR [SoapUITestCaseRunner] ASSERTION FAILED -> Comparison failed for path [$..status[0]], expecting [available], actual was [[]] 17:59:44,373 ERROR [SoapUITestCaseRunner] Get available pets failed, exporting to [/home/ubuntu/MyRepo/git/TSM/hestia-software-scripts/Simple__REST_Only__success/JSON_path_match_assertion/Get_available_pets-0-FAILED.txt] 17:59:44,373 ERROR [SoapUITestCaseRunner] Get available pets failed, exporting to [/home/ubuntu/MyRepo/git/TSM/hestia-software-scripts/Simple__REST_Only__success/JSON_path_match_assertion/Get_available_pets-0-FAILED.txt] 17:59:44,373 INFO [SoapUITestCaseRunner] Finished running SoapUI testcase [JSON path match assertion], time taken: 3ms, status: FAILED 17:59:44,374 INFO [SoapUITestCaseRunner] Running SoapUI testcase [JSON path regex match assertion] 17:59:44,374 INFO [SoapUITestCaseRunner] running step [Get available pets] 17:59:44,399 INFO [SoapUITestCaseRunner] Assertion [JsonPath RegEx Match - Pet name is valid] has status FAILED 17:59:44,400 ERROR [SoapUITestCaseRunner] ASSERTION FAILED -> Comparison failed for path [$..name[0]], expecting [true], actual was [false] 17:59:44,400 ERROR [SoapUITestCaseRunner] ASSERTION FAILED -> Comparison failed for path [$..name[0]], expecting [true], actual was [false] 17:59:44,400 ERROR [SoapUITestCaseRunner] Get available pets failed, exporting to [/home/ubuntu/MyRepo/git/TSM/hestia-software-scripts/Simple__REST_Only__success/JSON_path_regex_match_assertion/Get_available_pets-0-FAILED.txt] 17:59:44,400 ERROR [SoapUITestCaseRunner] Get available pets failed, exporting to [/home/ubuntu/MyRepo/git/TSM/hestia-software-scripts/Simple__REST_Only__success/JSON_path_regex_match_assertion/Get_available_pets-0-FAILED.txt] 17:59:44,402 INFO [SoapUITestCaseRunner] Finished running SoapUI testcase [JSON path regex match assertion], time taken: 2ms, status: FAILED 17:59:44,405 INFO [SoapUITestCaseRunner] TestSuite [Simple - REST Only - success] finished with status [FAILED] in 1179ms SoapUI 5.7.0 TestCaseRunner Summary ----------------------------- Time Taken: 1185ms Total TestSuites: 1 Total TestCases: 5 (2 failed) Total TestSteps: 5 Total Request Assertions: 4 Total Failed Assertions: 2 Total Exported Results: 5
已尝试的排查方案
- 确认相同参数在SoapUI 5.6.1版本下可正常执行,排除业务代码、Mock服务、入参本身的问题
- 了解到SoapUI高版本存在
JsonPath Match断言相关bug,曾尝试将相关断言替换为XPath Match,但问题仍未解决,依旧出现相同报错
恳请各位提供相关解决思路。
此致
Sabrina
内容的提问来源于stack exchange,提问作者Brini
相关产品推荐
相关产品推荐

