Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test page showing inputs and expectations - for regression testing #26

Open
GoogleCodeExporter opened this issue Sep 16, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Having the test page tests/jsonpath-test-js.html show a variety of example 
objects, expressions and results is really useful. 

To make sense of it you need to review the output of the page (in a browser) - 
which only shows the results - side-by-side with the HTML source. 

The attached is an attempt to put all the useful information in the viewable 
page - namely what the source data object was and the input expression. Further 
to this I've included the expectations to potentially allow for regression 
testing - e.g. comparison of behaviour for different jsonpath.js versions by 
seeing what "fails" the expected vs actual test. 

So in summary, starting with the jsonpath-test-js.html, the changes in the 
attached include:
- reference to jsonpath.js is relative from /tests (../src/js/jsonpath.js)
- removed reference to json.js and using JSON.stringify(..) instead
- display (in tabular layout) the source data, expression and results
- structure of the test data changed to be (excuse the made up JSON schema):
     var suite =  [ <test-objects> ];
     <test-object>:  { 
        "comment": <optional test comment>,
        "data": <source object>,
        "tests": [ <expression-test-objects> ]
    }
    <expression-test-objects>: { 
         "expr": <jsonpath expression>, 
         "comment": <optional expression comment>,
         "paths": [ <expected PATH result as 0-to-many paths> ], 
         "values": [ <expected VALUE result as 0-to-many paths> ]
    }
- each expression test runs the path and value tests separately and compares 
the results with the expectations. This is different to jsonpath-test-js.html 
which only obtained the "PATH" result then obtained the values via 'evaluate'. 
Presently, there's one test failing the "VALUE" result (Test #2, Expression 
#1). 
- if a comparison between expected & actual fails, the actual result is 
stringified onto the page (perhaps to help update expectations)
- no-result 'false' is turned into empty array [] 
- added in the 'bookstore' data and example expressions and expectations from 
the Wiki 


I'm hoping someone else finds this useful ... 

Consider for inclusion in the project? Potentially, new issues could be 
captured as new "<test-object>" definitions - showing the expectation, and the 
page will show if it fails. 



Original issue reported on code.google.com by kevin.ja...@exari.com on 16 Jul 2013 at 2:46

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant