You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by GitBox <gi...@apache.org> on 2022/10/19 10:45:19 UTC

[GitHub] [jmeter] lehmannk opened a new pull request, #5717: Add jsonpath string to jsonpath assertion error message

lehmannk opened a new pull request, #5717:
URL: https://github.com/apache/jmeter/pull/5717

   ## Description
   This PR adds the jsonpath string to the jsonpath assertion error message so it is easier to understand the actual error.
   
   ## Motivation and Context
   Currently, the jsonpath error produced when a mismatch occurs is not easy to understand because it does not contain the underlying analyzed jsonpath. 
   
   Example: 
   ```
   Assertion error:false
   Assertion failure:true
   Assertion failure message:Value expected to be 'true', but found '[]'
   ```
   There is no way to understand what is expected to be 'true' here.
   
   Thus, the actual jsonpath which caused the error shall be added, example:
   ```
   Assertion error:false
   Assertion failure:true
   Assertion failure message:Value in json path '$.response.valid' expected to be 'true', but found '[]'
   ```
   
   ## How Has This Been Tested?
   tested locally
   
   ## Screenshots (if appropriate):
   
   ## Types of changes
   - New feature (non-breaking change which adds functionality)
   
   ## Checklist:
   - [ x] My code follows the [code style][style-guide] of this project.
   - [ x] I have updated the documentation accordingly.
   
   [style-guide]: https://wiki.apache.org/jmeter/CodeStyleGuidelines
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] lehmannk commented on pull request #5717: Add jsonpath string to jsonpath assertion error message

Posted by GitBox <gi...@apache.org>.
lehmannk commented on PR #5717:
URL: https://github.com/apache/jmeter/pull/5717#issuecomment-1283923537

   modified the requested statements and fixed unit tests accordingle


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] vlsi commented on a diff in pull request #5717: Add jsonpath string to jsonpath assertion error message

Posted by GitBox <gi...@apache.org>.
vlsi commented on code in PR #5717:
URL: https://github.com/apache/jmeter/pull/5717#discussion_r1008671507


##########
src/components/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java:
##########
@@ -137,15 +137,15 @@ private void doAssert(String jsonString) {
         }
 
         if (isExpectNull()) {
-            throw new IllegalStateException(String.format("Value expected to be null, but found '%s'", value));
+            throw new IllegalStateException(String.format("Value in json path '%s' expected to be null, but found '%s'", getJsonPath(), value));

Review Comment:
   Should `value` be `objectToString(value)` like below?



##########
src/components/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java:
##########
@@ -118,8 +118,8 @@ private void doAssert(String jsonString) {
             if (value instanceof JSONArray) {
                 JSONArray arrayValue = (JSONArray) value;
                 if (arrayValue.isEmpty() && !JsonPath.isPathDefinite(getJsonPath())) {
-                    throw new IllegalStateException("JSONPath is indefinite and the extracted Value is an empty Array." +
-                            " Please use an assertion value, to be sure to get a correct result. " + getExpectedValue());
+                    throw new IllegalStateException(String.format("JSONPath '%s' is indefinite and the extracted Value is an empty Array." +
+                            " Please use an assertion value, to be sure to get a correct result. '%s'", getJsonPath(), getExpectedValue()));

Review Comment:
   ```suggestion
                               " Please use an assertion value, to be sure to get a correct result. Expected value was '%s'", getJsonPath(), getExpectedValue()));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] vlsi closed pull request #5717: Add jsonpath string to jsonpath assertion error message

Posted by GitBox <gi...@apache.org>.
vlsi closed pull request #5717: Add jsonpath string to jsonpath assertion error message
URL: https://github.com/apache/jmeter/pull/5717


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] lehmannk commented on pull request #5717: Add jsonpath string to jsonpath assertion error message

Posted by GitBox <gi...@apache.org>.
lehmannk commented on PR #5717:
URL: https://github.com/apache/jmeter/pull/5717#issuecomment-1350501312

   Hi @vlsi can you finally approve this PR? All your requested changes are incorporated.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] lehmannk commented on a diff in pull request #5717: Add jsonpath string to jsonpath assertion error message

Posted by GitBox <gi...@apache.org>.
lehmannk commented on code in PR #5717:
URL: https://github.com/apache/jmeter/pull/5717#discussion_r1016761907


##########
src/components/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java:
##########
@@ -137,15 +137,15 @@ private void doAssert(String jsonString) {
         }
 
         if (isExpectNull()) {
-            throw new IllegalStateException(String.format("Value expected to be null, but found '%s'", value));
+            throw new IllegalStateException(String.format("Value in json path '%s' expected to be null, but found '%s'", getJsonPath(), value));

Review Comment:
   I accepted your changes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org