Test Suite Help!

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Test Suite Help!

Jonathan Rowell

Hi,


I'm going a bit bananas with the test suite. I have a test which expects an error. The documentation reads :-


%test:assertError($errString)

Evaluating the tested function should result in a dynamic error. If value is given, it should either be a string contained in the error description or correspond to the error code of the dynamic error.

The annotation value is executed as an XPath expression. The assert passes if the XPath expression returns a non-empty sequence or a single atomic item whose effective boolean value is true. Within the XPath expression, the variable $resultcontains a reference to the result sequence returned by the tested function.


The first part implies I should test against the error message. The test is then :-


%test:args("fee-paid","1") %test:assertError('sipp:YesOrNo Field "fee-paid" is not Y or N, value is "1"')

and the JSON reply is :=


testcase entry: { '$': { name: 'sipp-test:YesOrNo', class: 'sipp-test:YesOrNo' },
  failure: [ { '$': [Object] } ] }

failure entry: { message: 'Expected error sipp:YesOrNo Field "fee-paid" is not Y or N, value is "1", got: sipp:YesOrNo Field "fee-paid" is not Y or N, value is "1"',
                 type: 'failure-error-code-1' }

"failure entry" being the bit in the Object "failure". This is the original XML that was sent back :-

<testcase name=\"sipp-test:YesOrNo\" class=\"sipp-test:YesOrNo\">\n
   <failure message=\"Expected error sipp:YesOrNo Field &#34;fee-paid&#34; is not Y or N, value is &#34;0&#34;, got: sipp:YesOrNo Field &#34;fee-paid&#34; is not Y or N, value is &#34;0&#34;\" type=\"failure-error-code-1\"/>\n
</testcase>\n

As far as I can see the messages are identical. 

However I do not understand the second paragraph of the documentation. What "annotation value"?

Help!

Jonathan




------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Test Suite Help!

Joe Wicentowski
Jonathan,

I fear the styling of your question was mangled and obscures your question.  Could you please re-post with plain text? :-)

Joe

Sent from my iPhone

On Mar 12, 2017, at 2:52 PM, Jonathan Rowell <[hidden email]> wrote:

Hi,


I'm going a bit bananas with the test suite. I have a test which expects an error. The documentation reads :-


%test:assertError($errString)

Evaluating the tested function should result in a dynamic error. If value is given, it should either be a string contained in the error description or correspond to the error code of the dynamic error.

The annotation value is executed as an XPath expression. The assert passes if the XPath expression returns a non-empty sequence or a single atomic item whose effective boolean value is true. Within the XPath expression, the variable $resultcontains a reference to the result sequence returned by the tested function.


The first part implies I should test against the error message. The test is then :-


%test:args("fee-paid","1") %test:assertError('sipp:YesOrNo Field "fee-paid" is not Y or N, value is "1"')

and the JSON reply is :=


testcase entry: { '$': { name: 'sipp-test:YesOrNo', class: 'sipp-test:YesOrNo' },
  failure: [ { '$': [Object] } ] }

failure entry: { message: 'Expected error sipp:YesOrNo Field "fee-paid" is not Y or N, value is "1", got: sipp:YesOrNo Field "fee-paid" is not Y or N, value is "1"',
                 type: 'failure-error-code-1' }

"failure entry" being the bit in the Object "failure". This is the original XML that was sent back :-

<testcase name=\"sipp-test:YesOrNo\" class=\"sipp-test:YesOrNo\">\n
   <failure message=\"Expected error sipp:YesOrNo Field &#34;fee-paid&#34; is not Y or N, value is &#34;0&#34;, got: sipp:YesOrNo Field &#34;fee-paid&#34; is not Y or N, value is &#34;0&#34;\" type=\"failure-error-code-1\"/>\n
</testcase>\n

As far as I can see the messages are identical. 

However I do not understand the second paragraph of the documentation. What "annotation value"?

Help!

Jonathan



------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Test Suite Help!

Jonathan Rowell

HiJoe,


Yes, probably a bit too deep in the pool!   I'll try and simplify.


If I create an error like :-


         error(xs:QName('sipp:YesOrNo'),concat('Field "',$name,'" is not Y or N, value is "',$value,'"'))


which produces  Field "fee-paid" is not Y or N, value is "1"


when I test with  


               %test:args("fee-paid","1")


what should go in the %test:assertError() ?


The pattern I'm using follows https://gist.github.com/joewiz/fa32be80749a69fcb8da but there is no example of assertError().

gist.github.com
Unit testing XQuery with XQSuite in eXist-db: tests for a sample function, how to run tests, and test results
What I first put in was the string returned from the concat(). That didn't work.

Then I prefixed the message with the QName, since the returned message under <testcase> contained it. That didn't work either.

Then I reread the documentation and decided I didn't understand it.

Then I searched the web and found a conflicting explanation in WikiBooks (the assert takes an "error code"?)

And then I wrote an E-Mail and retired to bed with my cold.


All the errors I generate in my app are distinct - so I'd like to invoke every single one.


The others, assertTrue, assertFalse and assertXPath all work wonderfully!


BTW I have written a grunt plugin which runs the test modules under the app's test collection.


Jonathan










From: Joe Wicentowski <[hidden email]>
Sent: Sunday, March 12, 2017 7:35 PM
To: Jonathan Rowell
Cc: eXist open
Subject: Re: [Exist-open] Test Suite Help!
 
Jonathan,

I fear the styling of your question was mangled and obscures your question.  Could you please re-post with plain text? :-)

Joe

Sent from my iPhone

On Mar 12, 2017, at 2:52 PM, Jonathan Rowell <[hidden email]> wrote:

Hi,


I'm going a bit bananas with the test suite. I have a test which expects an error. The documentation reads :-


%test:assertError($errString)

Evaluating the tested function should result in a dynamic error. If value is given, it should either be a string contained in the error description or correspond to the error code of the dynamic error.

The annotation value is executed as an XPath expression. The assert passes if the XPath expression returns a non-empty sequence or a single atomic item whose effective boolean value is true. Within the XPath expression, the variable $resultcontains a reference to the result sequence returned by the tested function.


The first part implies I should test against the error message. The test is then :-


%test:args("fee-paid","1") %test:assertError('sipp:YesOrNo Field "fee-paid" is not Y or N, value is "1"')

and the JSON reply is :=


testcase entry: { '$': { name: 'sipp-test:YesOrNo', class: 'sipp-test:YesOrNo' },
  failure: [ { '$': [Object] } ] }

failure entry: { message: 'Expected error sipp:YesOrNo Field "fee-paid" is not Y or N, value is "1", got: sipp:YesOrNo Field "fee-paid" is not Y or N, value is "1"',
                 type: 'failure-error-code-1' }

"failure entry" being the bit in the Object "failure". This is the original XML that was sent back :-

<testcase name=\"sipp-test:YesOrNo\" class=\"sipp-test:YesOrNo\">\n
   <failure message=\"Expected error sipp:YesOrNo Field &#34;fee-paid&#34; is not Y or N, value is &#34;0&#34;, got: sipp:YesOrNo Field &#34;fee-paid&#34; is not Y or N, value is &#34;0&#34;\" type=\"failure-error-code-1\"/>\n
</testcase>\n

As far as I can see the messages are identical. 

However I do not understand the second paragraph of the documentation. What "annotation value"?

Help!

Jonathan



------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open