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

On failure, x:expect with context reports the entire result, not the specified context #33

Closed
AirQuick opened this issue Dec 23, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@AirQuick
Copy link
Member

test.xsl (just returns the input node intact)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="#all" version="2.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template as="node()" match="node()">
		<xsl:sequence select="." />
	</xsl:template>
</xsl:stylesheet>

test_old.xspec (tests test.xsl by looking for descendant::baz)

<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="test.xsl" xmlns:x="http://www.jenitennison.com/xslt/xspec">
	<x:scenario label="Scenario-old">
		<x:context><foo><bar><baz>original-text</baz></bar></foo></x:context>
		<x:expect label="Expect success" test="descendant::baz"><baz>original-text</baz></x:expect>
		<x:expect label="Expect failure" test="descendant::baz"><baz>broken-text</baz></x:expect>
	</x:scenario>
</x:description>

x:expect label="Expect failure" is expected to fail, because of the text node difference.

With XSpec 0.3.0, the failure report HTML is generated as follows. (Indent and xmlns omitted for brevity)

Result Expecting
<baz>original-text</baz> <baz>broken-text</baz>

So far, so good.

XSpec 0.4.0-RC changed the recommended way to describe the same x:expect. (Just my guess... Any clarification or documentation welcomed.)

test_new.xspec (test attribute in test_old.xspec is replaced with context attribute)

<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="test.xsl" xmlns:x="http://www.jenitennison.com/xslt/xspec">
	<x:scenario label="Scenario-new">
		<x:context><foo><bar><baz>original-text</baz></bar></foo></x:context>
		<x:expect label="Expect success" context="descendant::baz"><baz>original-text</baz></x:expect>
		<x:expect label="Expect failure" context="descendant::baz"><baz>broken-text</baz></x:expect>
	</x:scenario>
</x:description>

Running this scenario with the latest master, the failure report HTML is generated as follows. (Indent omitted for brevity)

Result Expecting
<foo><bar><baz>original-text</baz></bar></foo> <baz>broken-text</baz>

Notice the left-hand Result is the entire result, not <baz>original-text</baz> which 0.3.0 used to report.

@cirulls
Copy link
Member

cirulls commented Dec 23, 2016

Thanks for reporting this issue, I'll have a look and keep you posted. Please allow me 7-10 days to get back to you as it is Christmas time.

@cirulls cirulls self-assigned this Dec 23, 2016
cirulls pushed a commit that referenced this issue Dec 27, 2016
- use x:output-expect from v0.3.0 to fix regression bugs in #26 #30 #33
- remove attributes assert and context of x:expect as assert seems a duplicate of test and there is no documentation on how these attributes should behave
- in the test suite remove x:expect for tests using attribute assert as they are all duplicates of test
- add more tests to cover #26 #30 #33
@cirulls cirulls added bug and removed question labels Dec 27, 2016
cirulls pushed a commit that referenced this issue Jan 1, 2017
* revert to x:output-expect from v0.3.0 #26 #30 #33

- use x:output-expect from v0.3.0 to fix regression bugs in #26 #30 #33
- remove attributes assert and context of x:expect as assert seems a duplicate of test and there is no documentation on how these attributes should behave
- in the test suite remove x:expect for tests using attribute assert as they are all duplicates of test
- add more tests to cover #26 #30 #33
@cirulls
Copy link
Member

cirulls commented Jan 1, 2017

I merged #38 and close this issue.

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

No branches or pull requests

2 participants