Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/test/java/io/xspec/maven/xspecMavenPlugin/XSpecRunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.util.List;
import java.util.Properties;
import net.sf.saxon.s9api.XdmNode;
Expand Down Expand Up @@ -152,6 +153,32 @@ public void findAllXSpecsTestsDirWithoutXspecFiles() throws Exception {
assertEquals("wrong number of XSpecFiles found", 0, xspecFiles.size());
}

@Test
public void verifyFailingXSpecIsReported() throws Exception {
RunnerOptions runnerOptions = new RunnerOptions(getProjectDirectory());
runnerOptions.testDir = new File(getTestDirectory(), "failingXslt");
XSpecRunner runner = getNewRunner(new SaxonOptions(), runnerOptions);
List<File> xspecFiles = runner.findAllXSpecs();
assertEquals("wrong number of XSpecFiles found", 2, xspecFiles.size());
try {
runner.execute();
fail("Should have given an error");
} catch (XSpecPluginException ex) {
// XSpec test should be missed
}
runner.generateIndex();
File surefireReport = new File(getProjectDirectory(), "target/surefire-reports/TEST-xsl1.xspec.xml");
assertTrue("Surefire report doesn't exist", surefireReport.exists());
assertTrue("Surefire report is not a file", surefireReport.isFile());
assertFalse("Surefire report should report on failing test",
Files.readString(surefireReport.toPath()).contains("<testsuites/>"));
File surefireReport2 = new File(getProjectDirectory(), "target/surefire-reports/TEST-xsl2.xspec.xml");
assertTrue("Surefire report 2 doesn't exist", surefireReport2.exists());
assertTrue("Surefire report 2 is not a file", surefireReport2.isFile());
assertFalse("Surefire report 2 should report on failing test",
Files.readString(surefireReport2.toPath()).contains("<testsuites/>"));
}

private XSpecRunner getNewRunner(SaxonOptions saxonOptions, RunnerOptions runnerOptions) throws IllegalStateException, XSpecPluginException, MalformedURLException, URISyntaxException {
XSpecRunner runner = new XSpecRunner(getLog(), getBaseDirectory());
runner.setResources(
Expand Down
16 changes: 16 additions & 0 deletions src/test/resources/filesToTest/failingXslt/xsl1.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:private="io:xspec:xspec-maven-plugin:tests"
exclude-result-prefixes="xs math xd"
version="3.0">

<xsl:function name="private:add" as="xs:integer">
<xsl:param name="n1" as="xs:integer"/>
<xsl:param name="n2" as="xs:integer"/>
<xsl:message terminate="yes"/>
</xsl:function>

</xsl:stylesheet>
15 changes: 15 additions & 0 deletions src/test/resources/filesToTest/failingXslt/xsl1.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:private="io:xspec:xspec-maven-plugin:tests"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
stylesheet="xsl1.xsl">

<x:scenario label="Testing function add">
<x:call function="private:add">
<x:param as="xs:integer" select="1"/>
<x:param as="xs:integer" select="4"/>
</x:call>
<x:expect label="5" select="5"/>
</x:scenario>
</x:description>
7 changes: 7 additions & 0 deletions src/test/resources/filesToTest/failingXslt/xsl2.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0">

<xsl:

</xsl:stylesheet>
15 changes: 15 additions & 0 deletions src/test/resources/filesToTest/failingXslt/xsl2.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:private="io:xspec:xspec-maven-plugin:tests"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
stylesheet="xsl2.xsl">

<x:scenario label="Testing function add">
<x:call function="private:add">
<x:param as="xs:integer" select="1"/>
<x:param as="xs:integer" select="4"/>
</x:call>
<x:expect label="5" select="5"/>
</x:scenario>
</x:description>